-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8416be
commit a4faa05
Showing
82 changed files
with
5,386 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,99 @@ | ||
# SldWorks.TestRunner | ||
TestRunner for SolidWorks | ||
# SolidWorks.TestRunner | ||
|
||
SolidWorks.TestRunner is a simple Addin for SolidWorks. It runs unit tests from a specified test assembly, which have references to the Revit API. The test framework used is [NUnit v3](https://github.com/nunit). | ||
|
||
## How it works | ||
The SolidWorks.TestRunner is designed to work as an Addin of SolidWorks. This means you must start SolidWorks by yourself, start the SolidWorks.TestRunner, chose your favorite test assembly and run the selected tests. There is no need for the test assembly to have any reference to the TestRunner. All you have to do, is get the nuget package of NUnit and write some fancy tests. | ||
|
||
## Install | ||
|
||
Click *.bat file to Install or UnInstall. | ||
|
||
<div> | ||
<img width="300" src="images/installBat.png"> | ||
</div> | ||
|
||
## Getting started | ||
Get the Code from github and compile it. The Revit.TestRunner.addin file will be automatically Registed. | ||
|
||
It is also possible to download the pre compiled binaries. | ||
|
||
The Addin hooks in the Taskpane of SolidWorks. | ||
|
||
<div> | ||
<img height="600" src="images/SldWorksTestRunner.png"> | ||
</div> | ||
|
||
By choosing your testing assembly, the view will show all your tests. | ||
|
||
<div> | ||
<img height="600" src="images/ui.png"> | ||
</div> | ||
|
||
Select the node you want to test and press the ‘Run’. All tests below the selected node will be executed. | ||
|
||
<div> | ||
<img height="600" src="images/executed.png"> | ||
</div> | ||
|
||
### 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. | ||
|
||
```c# | ||
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 Revit and make some test with it. This is not easy because we need the `Application` API object of Revit, but we don’t have it available at this point. | ||
To get the API object, change the signature of your Test Method. The Revit.TestFramework will inject the desired object in the Test, SetUp or TearDown Method. Supported Revit Objects: `UIApplication`, `Application`) | ||
|
||
```c# | ||
[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](http://opensource.org/licenses/MIT) | ||
|
||
## Thanks | ||
|
||
1. [Revit.TestRunner](https://github.com/geberit/Revit.TestRunner) | ||
|
||
2. [xcad](https://github.com/xarial/xcad) | ||
|
||
3. [MahApps.Metro](https://github.com/MahApps/MahApps.Metro) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Documentation | ||
|
||
## Intension | ||
|
||
The goal of this add-in is to write test for your add-in. Because it is not possible to start revit as a 'service' or start from a test, it is necessary to start Revit first, then start your tests. In this case, the Revit context is available in the tests. | ||
|
||
## Writing Tests | ||
|
||
First add the NuGet package of [NUnit](https://www.nuget.org/packages/NUnit/) to the test project. | ||
|
||
A test must be marked with the ```Test``` Attribute of the NUnit 3 library. All marked methods will be recognized when the test assembly is loaded. A ```Test``` is executable. | ||
A method marked with the ```SetUp``` Attribute will be executed before each test. | ||
A method marked with the ```TearDown``` Attribute will be executed after each test. | ||
|
||
```C# | ||
[SetUp] | ||
public void MySetUp(){ | ||
// Do some stuff before the test runs. | ||
} | ||
|
||
[TearDown] | ||
public void MyTearDown(){ | ||
// Do some stuff after the test is finished | ||
} | ||
|
||
[Test] | ||
public void MyTest(){ | ||
// Do some test stuff | ||
} | ||
``` | ||
|
||
|
||
To get SolidWorks API objects like ```ISldWorks``` , extend the test method signature with one or both of the called Classes. The injected objects can be used to do some stuff, for example open a file. | ||
|
||
```C# | ||
[Test] | ||
public void MyTest( UIApplication uiApplication){ | ||
// Do some test stuff. ex.: | ||
uiApplication.Application.OpenDocumentFile( "C:\myTestFile.rvt" ); | ||
} | ||
``` | ||
|
||
A sample test assembly is included in the visual studio solution. | ||
|
||
## VisualStudio Solution | ||
|
||
### Sample Test Project | ||
|
||
Containing some sample Tests, showing how they could be implemented. | ||
|
||
### Build the Solution | ||
|
||
The CADFrameWorks developed by https://xcad.xarial.com/ is Used for this project.Build action will auto registed addin for solidworks. Clear action will delete the addin inforamtion. | ||
|
||
## Precompiled binaries | ||
|
||
The compiled add-in is also available in the [install](../install) section. Download the whole directory and place it somewhere. Run the corresponding .cmd to install the add-in. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Reflection; | ||
using System.Resources; | ||
|
||
[assembly: AssemblyCompany( "Geberit Verwaltungs AG" )] | ||
[assembly: AssemblyProduct( "Revit TestRunner" )] | ||
[assembly: AssemblyCopyright( "Copyright © 2002-2019, Geberit Verwaltungs AG." )] | ||
[assembly: AssemblyTrademark( "" )] | ||
[assembly: AssemblyCulture( "" )] | ||
|
||
[assembly: NeutralResourcesLanguage( "en-US" )] | ||
[assembly: AssemblyTitle( "Revit.TestRunner" )] | ||
[assembly: AssemblyDescription( "UnitTest Runner for Revit" )] | ||
|
||
#if DEBUG | ||
|
||
[assembly: AssemblyConfiguration( "Debug Build" )] | ||
#else | ||
|
||
[assembly: AssemblyConfiguration( "Release Build" )] | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion( "0.10.1.0" )] | ||
[assembly: AssemblyFileVersion( "0.10.1.0" )] | ||
|
||
[assembly: AssemblyInformationalVersion( "0.10.1.0" )] |
54 changes: 54 additions & 0 deletions
54
src/CADApplication.GrpcModel/CADApplication.GrpcModel.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>4e7c9516-9345-4dc5-8527-2d37c4af86f8</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CADApplication.GrpcModel</RootNamespace> | ||
<AssemblyName>CADApplication.GrpcModel</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System"/> | ||
|
||
<Reference Include="System.Core"/> | ||
<Reference Include="System.Xml.Linq"/> | ||
<Reference Include="System.Data.DataSetExtensions"/> | ||
|
||
|
||
<Reference Include="Microsoft.CSharp"/> | ||
|
||
<Reference Include="System.Data"/> | ||
|
||
<Reference Include="System.Net.Http"/> | ||
|
||
<Reference Include="System.Xml"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Class1.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CADApplication.GrpcModel | ||
{ | ||
public class Class1 | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的一般信息由以下 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("CADApplication.GrpcModel")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CADApplication.GrpcModel")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 会使此程序集中的类型 | ||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 | ||
//请将此类型的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("4e7c9516-9345-4dc5-8527-2d37c4af86f8")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 | ||
//通过使用 "*",如下所示: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.