I have 3 NUnit test assemblies are testing my custom code written for the Kentico CMS platform. I can run these tests both in Visual Studio (using the NUnit adapter) and the NUnit console runner. I'm now trying to have those tests run on my TeamCity build server. I've got the NUnit runner setup and it is returning some results, but I'm finding that not all the tests are being executed. In one case, one of my assemblies reports having no test fixtures despite the fact I know there definitely are.
System Details
- TeamCity v10.0.5 (build 42677)
- Nunit 3.8.1
- Nunit.ConsoleRunner 3.8.0
- Kentico 11
- Kentico.Libraries - 11.0.35
- Kentico.Libraries.Tests - 11.0.35
Problem 1
I have a test assembly called gto.ecommerce.core.tests.dll
. When this is run on the TeamCity server, I get this output (straight from the NUnit console runner):
NUnit Console Runner 3.8.0
Copyright (c) 2018 Charlie Poole, Rob Prouse
Runtime Environment
OS Version: Microsoft Windows NT 6.3.9600.0
CLR Version: 4.0.30319.42000
Test Files
D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\Tests\gto.ecommerce.core.tests\bin\Build\gto.ecommerce.core.tests.dll
Run Settings
DisposeRunners: True
WorkDirectory: D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\packages\NUnit.ConsoleRunner.3.8.0\tools
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.6
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 8
Test Run Summary
Overall result: Passed
Test Count: 6, Passed: 6, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-01-15 10:16:53Z
End time: 2019-01-15 10:16:54Z
Duration: 1.219 seconds
Results (nunit3) saved as TestResult.xml
These are exactly the same results returned when the TeamCity build step is run as well.
However, there should be more tests here. If I copy the binaries that TeamCity built to my local machine and run the same NUnit console runner command, I get these results:
NUnit Console Runner 3.8.0
Copyright (c) 2018 Charlie Poole, Rob Prouse
Runtime Environment
OS Version: Microsoft Windows NT 10.0.14393.0
CLR Version: 4.0.30319.42000
Test Files
C:\temp\gto-gtoengineering\TeamCity\gto.ecommerce.core.tests\Build\gto.ecommerce.core.tests.dll
Run Settings
DisposeRunners: True
WorkDirectory: Z:\
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.6
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 8
Test Run Summary
Overall result: Passed
Test Count: 33, Passed: 33, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-01-15 10:19:31Z
End time: 2019-01-15 10:19:35Z
Duration: 4.494 seconds
Results (nunit3) saved as TestResult.xml
Notice how my machine says there are 33 tests overall, which is the correct number.
Problem 2
If I run the same scenarios on another assembly I have, rwy.common.core.tests
, then this is the TeamCity server result:
NUnit Console Runner 3.8.0
Copyright (c) 2018 Charlie Poole, Rob Prouse
Runtime Environment
OS Version: Microsoft Windows NT 6.3.9600.0
CLR Version: 4.0.30319.42000
Test Files
D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\Tests\rwy.common.core.tests\bin\Build\rwy.common.core.tests.dll
Errors, Failures and Warnings
1) Invalid : D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\Tests\rwy.common.core.tests\bin\Build\rwy.common.core.tests.dl
l
Has no TestFixtures
Run Settings
DisposeRunners: True
WorkDirectory: D:\TeamCity\buildAgent\work\4a231fb0e41e27f5\packages\NUnit.ConsoleRunner.3.8.0\tools
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.6
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 8
Test Run Summary
Overall result: Failed
Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-01-15 10:21:16Z
End time: 2019-01-15 10:21:17Z
Duration: 1.046 seconds
Results (nunit3) saved as TestResult.xml
But again, I copy the same binaries to my local machine and I get this result:
NUnit Console Runner 3.8.0
Copyright (c) 2018 Charlie Poole, Rob Prouse
Runtime Environment
OS Version: Microsoft Windows NT 10.0.14393.0
CLR Version: 4.0.30319.42000
Test Files
C:\temp\gto-gtoengineering\TeamCity\rwy.common.core.tests\Build\rwy.common.core.tests.dll
Run Settings
DisposeRunners: True
WorkDirectory: Z:\
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.6
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 8
Test Run Summary
Overall result: Passed
Test Count: 20, Passed: 20, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-01-15 10:22:55Z
End time: 2019-01-15 10:23:00Z
Duration: 4.242 seconds
Results (nunit3) saved as TestResult.xml
There should definitely be 20 tests available, but when run on the TeamCity server it says it cannot find any.
Summary
So does anyone know why two different machines running what I assume to be the same versions of NUnit and console runner produce vastly different results? I cannot see any obvious differences in version numbers apart from Windows, but the same .NET framework should be being used I think.
I do use a significant number of TestCaseSource
and TestFixtureSource
attributes to increase my test count for parameterized tests, but I'm not sure that is the cause - if it works on one machine I cannot see why another would be different.