Skip to content

Commit

Permalink
TestCases added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasfloescher-geberit committed Jun 5, 2020
1 parent 4c1788c commit 80cc673
Show file tree
Hide file tree
Showing 10 changed files with 9,292 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/src/Revit.TestRunner/obj/x64
/.vs
/src/.vs
/src/Revit.TestRunner/Revit.TestRunner.csproj.user
8 changes: 8 additions & 0 deletions src/Revit.TestRunner.SampleTestProject/ParameterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,13 @@ public void MultiParameterTest2( Application application, UIApplication uiApplic
Assert.IsNotNull( uiApplication );
Assert.IsNotNull( application );
}

[TestCase( 12, 3, ExpectedResult = 15 )]
[TestCase( 13, 7, ExpectedResult = 20 )]
[TestCase( 15, 4, ExpectedResult = 19 )]
public int SumTest( int n, int d )
{
return n + d;
}
}
}
13 changes: 11 additions & 2 deletions src/Revit.TestRunner/Runner/Direct/ReflectionRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ internal void RunTest( NodeViewModel test, UIApplication uiApplication )
testMethod = type.GetMethod( methodName );
tearDown = GetMethodByAttribute( type, typeof( TearDownAttribute ) );

var customAttributes = testMethod.CustomAttributes;
var extendedParams = possibleParams.ToList();

foreach( CustomAttributeData customAttribute in customAttributes ) {
extendedParams.AddRange( customAttribute.ConstructorArguments.Select( a => a.Value ) );
}

Invoke( obj, setUp, possibleParams );
Invoke( obj, testMethod, possibleParams );
Invoke( obj, testMethod, extendedParams.ToArray() );

test.State = TestState.Passed;
}
Expand Down Expand Up @@ -90,9 +97,11 @@ private object[] OrderParameters( MethodInfo methodInfo, object[] possibleParams
{
var result = new List<object>();
var parameters = methodInfo.GetParameters();
var possibleParamsList = possibleParams.ToList();

foreach( ParameterInfo parameter in parameters ) {
object o = possibleParams.FirstOrDefault( i => i.GetType() == parameter.ParameterType );
object o = possibleParamsList.FirstOrDefault( i => i.GetType() == parameter.ParameterType );
possibleParamsList.Remove( o );
result.Add( o );
}

Expand Down
1 change: 1 addition & 0 deletions src/Revit.TestRunner/Runner/NUnit/NUnitResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private TestType ToType()
if( type == "Assembly" ) result = TestType.Assembly;
}

if( Node.Name == "test-suite" ) result = TestType.Suite;
if( Node.Name == "test-run" ) result = TestType.Run;
if( Node.Name == "test-case" ) result = TestType.Case;

Expand Down
23 changes: 23 additions & 0 deletions src/Revit.TestRunner/Runner/NUnit/NUnitRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ internal void ExploreAssembly()
}
}

/// <summary>
/// Run Tests with NUnit
/// https://github.com/nunit/docs/wiki/Test-Filters
/// </summary>
internal void Run( string test )
{
TestFilter filter = !string.IsNullOrEmpty( test )
? new TestFilter( $"<filter><test>{test}</test></filter>" )
: TestFilter.Empty;

try {
ITestRunner testRunner = CreateTestRunner();
XmlNode runResult = testRunner.Run( this, filter );
ExploreRun = new NUnitTestRun( runResult );

testRunner.Unload();
}
catch( Exception e ) {
Log.Debug( e );
MessageBox.Show( $"{e}", "Exception in NUnit" );
}
}

public void OnTestEvent( string report )
{
Log.Debug( report );
Expand Down
Binary file modified src/bin/Revit.TestRunner.SampleTestProject.dll
Binary file not shown.
Binary file modified src/bin/Revit.TestRunner.SampleTestProject.pdb
Binary file not shown.
Binary file modified src/bin/Revit.TestRunner.dll
Binary file not shown.
Binary file modified src/bin/Revit.TestRunner.pdb
Binary file not shown.
9,248 changes: 9,248 additions & 0 deletions src/bin/Test.Runner.log

Large diffs are not rendered by default.

0 comments on commit 80cc673

Please # to comment.