Skip to content

Commit

Permalink
Update to xUnit 2.4.1 (dotnet#265)
Browse files Browse the repository at this point in the history
* Update build instructions
  • Loading branch information
tminka committed Aug 24, 2020
1 parent b125394 commit e00a83e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 41 deletions.
19 changes: 4 additions & 15 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ When not using Windows, expect build failure messages about examples that use WP

Unit tests are written using the [XUnit](https://xunit.github.io/) framework.
The easiest way to run all tests is to execute the script `netcoretest.sh` or `monotest.sh`.
To run unit tests manually, build the test project and execute one of the following commands:
To run unit tests manually from the command line:
```bash
dotnet test Tests -c <configuration> <filter>
```
```bash
mono ~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe <path to net461 assembly with tests> <filter>
dotnet test Infer.sln -c <configuration> <filter>
```
See the scripts for example filters.

There are three test assemblies in the solution:

Expand All @@ -73,27 +71,18 @@ There are three test assemblies in the solution:
Depending on the build configuration and targeted framework, the assemblies will be located in the `bin/Debug<Core|Full>/<netcoreapp3.1|net461>` or `bin/Release<Core|Full>/<netcoreapp3.1|net461>` subdirectories
of the test project.

`<filter>` is a rule to choose what tests will be run. You can specify them
using `-trait Category=<category>` and `-notrait Category=<category>` parts
of `<filter>`. The former selects tests of
the given category, while the latter selects test that don't belong to the given
category. These can be combined: several `-trait` options mean that _at least one_ of the listed traits has to be present, while several `-notrait` options mean that _none_ of such traits can be present on the filtered tests.

Runner executes tests in parallel by default. However, some test category must be run
sequentially. Such categories are:
- _Performance_
- _DistributedTest_
- _CsoftModel_
- _ModifiesGlobals_

Add the `-parallel none` argument to run them.

_CompilerOptionsTest_ is a category for long running tests, so, for quick
testing you must filter these out by `-notrait`.
testing you must filter these out by `Category!=CompilerOptionsTest`.
_BadTest_ is a category of tests that must fail.
_OpenBug_ is a category of tests that can fail.

See the scripts for example filters.

## Fast matrix operations with Intel MKL
Matrix operations in Infer.NET can be significantly accelerated by building with Intel MKL support.
Expand Down
2 changes: 1 addition & 1 deletion test/TestFSharp/TestFSharp.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion test/TestPublic/TestPublic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 7 additions & 7 deletions test/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="0.10.0" />
<PackageReference Include="xunit.assert" Version="2.3.1" />
<PackageReference Include="xunit.core" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.3.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="xunit.runner.utility" Version="2.3.1" />
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.utility" Version="2.4.1" />
<ProjectReference Include="..\..\src\Compiler\Compiler.csproj" />
<ProjectReference Include="..\..\src\Csoft\Csoft.csproj" />
<ProjectReference Include="..\..\src\Runtime\Runtime.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion test/monotest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ html_parallel=parallel.html
html_sequential=sequential.html

# path to the xunit runner
runner=~/.nuget/packages/xunit.runner.console/2.3.1/tools/net452/xunit.console.exe
runner=~/.nuget/packages/xunit.runner.console/2.4.1/tools/net452/xunit.console.exe

# filter for parallel test run
parallel_filter='-notrait Platform=x86 -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance'
Expand Down
25 changes: 9 additions & 16 deletions test/netcoretest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ then
fi

compath=/bin/${configuration}/netcoreapp3.1/
projects="Learners/LearnersTests Tests TestPublic TestFSharp"

# filter for parallel test run
#parallel_filter='-notrait Platform=x86 -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance'
Expand All @@ -27,28 +26,22 @@ parallel_filter='--filter (Platform!=x86)&(Category!=OpenBug)&(Category!=BadTest
sequential_filter='--filter (Platform!=x86)&(Category!=OpenBug)&(Category!=BadTest)&(Category!=CompilerOptionsTest)&(Category=CsoftModel|Category=ModifiesGlobals|Category=DistributedTests|Category=Performance)'

exitcode=0
index=0

echo -e "\033[44;37m=====================PARALLEL TESTS RUNNING============================\033[0m"
cp "Tests/parallel.xunit.runner.json" "Tests/xunit.runner.json"
for project in $projects
do
# Please note that due to xUnit issue we need to run tests for each project separately
dotnet test "$project" -c "$configuration" $parallel_filter --logger "trx;logfilename=netcoretest-result${index}.trx"
if [ 0 -ne $? ]
then
echo -e "\033[5;41;1;37mParallel running failure!\033[0m"
exitcode=1
else
echo -e "\033[32;1mParallel running success!\033[0m"
fi
(( index++ ))
done
dotnet test ../Infer.sln -c "$configuration" $parallel_filter --logger "trx;logfilename=netcoretest-result.trx"
if [ 0 -ne $? ]
then
echo -e "\033[5;41;1;37mParallel running failure!\033[0m"
exitcode=1
else
echo -e "\033[32;1mParallel running success!\033[0m"
fi

echo -e "\033[44;37m=====================SEQUENTIAL TESTS RUNNING=========================\033[0m"
# See https://xunit.github.io/docs/configuration-files
cp "Tests/sequential.xunit.runner.json" "Tests/xunit.runner.json"
dotnet test Tests -c "$configuration" $sequential_filter --logger "trx;logfilename=netcoretest-result${index}.trx"
dotnet test Tests -c "$configuration" $sequential_filter --logger "trx;logfilename=netcoretest-result2.trx"
if [ 0 -ne $? ]
then
echo -e "\033[5;41;1;37mSequential running failure!\033[0m"
Expand Down

0 comments on commit e00a83e

Please sign in to comment.