JetBrains / JetBrains/TeamCity.VSTest.TestAdapter

No tests found when running dotnet test with TC TestAdapter

Open
#24 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
32
Forks
13
PR merge metrics
No merged PRs in 30d

Description

I have some trouble with test projects on TeamCity for which the tests stopped executing at some point (TC update, dotnet SDK update?!). Unfortunately, this did not cause the dotnet build step to fail and hence it went unnoticed for quite some time. I have traced back the problems to the TeamCity.VSTest.TestAdapter.
As a minimal example with similar behavior, consider a project with the following .csproject file
```


net471;netcoreapp2.0
packages






```

which contains a single source file (whose content is not really important, but included for completeness):
```
using NUnit.Framework;

namespace Example
{
public class Tests
{
[Test]
public void Test()
{
Assert.AreEqual(true, true);
}
}
}
```

If I run the tests with my local dotnet core SDK version 2.1.401, I get the expected results with both the netcoreapp2.0 and the net471 tests.

```
dotnet test --test-adapter-path:packages\teamcity.vstest.testadapter\1.0.10\build\_common\vstest15\ --logger:teamcity /p:TargetFramework=netcoreapp2.0
Build started, please wait...
Build completed.

Test run for C:\Users\frederik-h\tcbuildproblem\minimal-example\TestProject-With-TCAdapter\bin\Debug\netcoreapp2.0\Example.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 15.8.0
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
##teamcity[testSuiteStarted name='Example.dll' timestamp='2018-09-12T12:56:44.976+0000' flowId='f1c6ccda30164f138917f275df305d28']
##teamcity[testStarted name='Example.Tests.Test' captureStandardOutput='false' timestamp='2018-09-12T12:56:44.983+0000' flowId='f1c6ccda30164f138917f275df305d28']
##teamcity[testFinished name='Example.Tests.Test' duration='23' timestamp='2018-09-12T12:56:44.986+0000' flowId='f1c6ccda30164f138917f275df305d28']
##teamcity[testSuiteFinished name='Example.dll' timestamp='2018-09-12T12:56:44.987+0000' flowId='f1c6ccda30164f138917f275df305d28']

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.9936 Seconds
```

I get the same result if I run with ``/p:TargetFramework=net471``.

Now, if I set the SDK version to 2.1.301 (the version on our build agents) with ``dotnet new globaljson --sdk-version 2.1.301``, the netcoreapp2.0 tests still run with the same result.
But for net471 , I get:
```
dotnet test --test-adapter-path:packages\teamcity.vstest.testadapter\1.0.10\build\_common\vstest15\ --logger:teamcity /p:TargetFramework=net471
Build started, please wait...
Build completed.

Test run for C:\Users\frederik-h\tcbuildproblem\minimal-example\TestProject-With-TCAdapter\bin\Debug\net471\Example.dll(.NETFramework,Version=v4.7.1)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
No test is available in C:\Users\frederik-h\tcbuildproblem\minimal-example\TestProject-With-TCAdapter\bin\Debug\net471\Example.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
```

If I set the test adapter path by ``--test-adapter-path:.``, the net471 build works as well.
But for my actual project, using this variant does not work at all, whereas the variant with the explicit paths shows the same behavior as described here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.