Giter Site home page Giter Site logo

sldworks.testrunner's Introduction

SolidWorks.TestRunner

SolidWorks.TestRunner is a simple Addin for SolidWorks to run unit tests from a specified test assembly. The test framework used is NUnit v3.

Install

DownLoad

Click *.bat file to Install or UnInstall.

Getting started

The Addin hooks in the Taskpane of SolidWorks.

By choosing your testing assembly, the view will show all your tests.

Select the node you want to test and press the ‘Run’. All tests below the selected node will be executed.

Write Tests

Create a test project in your solution and get the NUnit nuget package.

Let’s have a look to the SampleTest class. As you see, test are marked by the NUnit Attribute ‘Test’. Also ‘SetUp’ and ‘TearDown’ Attributes are supported.

public class SampleTest
{
    [SetUp]
    public void RunBeforeTest()
    {
        Console.WriteLine( $"Run 'SetUp' in {GetType().Name}" );
    }
 
    [TearDown]
    public void RunAfterTest()
    {
        Console.WriteLine( $"Run 'TearDown' in {GetType().Name}" );
    }
 
    [Test]
    public void PassTest()
    {
        Assert.True( true );
    }
 
    [Test]
    public void FailTest()
    {
        Assert.True( false, "This Test should fail!" );
    }
}

And now we are happy, almost. It would be nice if we can open a file in SolidWorks and make some test with it. This is not easy because we need the ISldWorks API Interface of SolidWorks, but we don’t have it available at this point. To get the API Interface, change the signature of your Test Method. The SldWorks.TestRunner will inject the desired object in the Test, SetUp or TearDown Method.

[Test]
public void MultiParameterTest1(ISldWorks swApp)
{
    Assert.IsNotNull(swApp);
    swApp.SendMsgToUser("Hello SolidWorks");
}

In your test, you have access to it, and your able to make stuff with it (ex. swApp.NewDocument(partTemPath, 0, 0, 0) as IPartDoc)

License

MIT

Thanks

  1. Base on Revit.TestRunner.

  2. xcad used to implement a SolidWorks addin.

  3. MahApps.Metro -- UI Controls

sldworks.testrunner's People

Contributors

weianweigan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

curdie

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.