1+ using System . IO ;
12using System . Linq ;
23using Nuke . Common ;
34using Nuke . Common . IO ;
45using Nuke . Common . ProjectModel ;
56using Nuke . Common . Tooling ;
67using Nuke . Common . Tools . DotNet ;
7- using Nuke . Common . Tools . Xunit ;
8- using static Nuke . Common . Tools . Xunit . XunitTasks ;
8+ using Nuke . Common . Tools . NUnit ;
99using static Nuke . Common . Tools . DotNet . DotNetTasks ;
1010
1111// ReSharper disable AllUnderscoreLocalParameterName
@@ -14,61 +14,66 @@ namespace Build;
1414
1515partial class Build
1616{
17- Target UnitTests => _ => _
18- . DependsOn ( DotNetFrameworkUnitTests )
19- . DependsOn ( DotNetUnitTests ) ;
17+ Target UnitTests => _ => _
18+ . DependsOn ( DotNetFrameworkUnitTests )
19+ . DependsOn ( DotNetUnitTests ) ;
2020
21- Project [ ] UnitTestProjects =>
22- [
23- Solution . Tests . TestableIO_System_IO_Abstractions_Wrappers_Tests ,
24- Solution . Tests . TestableIO_System_IO_Abstractions_TestingHelpers_Tests ,
25- Solution . Tests . TestableIO_System_IO_Abstractions_Parity_Tests ,
26- ] ;
21+ Project [ ] UnitTestProjects =>
22+ [
23+ Solution . Tests . TestableIO_System_IO_Abstractions_Wrappers_Tests ,
24+ Solution . Tests . TestableIO_System_IO_Abstractions_TestingHelpers_Tests ,
25+ Solution . Tests . TestableIO_System_IO_Abstractions_Parity_Tests ,
26+ ] ;
2727
28- Target DotNetFrameworkUnitTests => _ => _
29- . Unlisted ( )
30- . DependsOn ( Compile )
31- . OnlyWhenDynamic ( ( ) => EnvironmentInfo . IsWin )
32- . Executes ( ( ) =>
33- {
34- string [ ] testAssemblies = UnitTestProjects
35- . SelectMany ( project =>
36- project . Directory . GlobFiles (
37- $ "bin/{ ( Configuration == Configuration . Debug ? "Debug" : "Release" ) } /net48 /*.Tests.dll") )
38- . Select ( p => p . ToString ( ) )
39- . ToArray ( ) ;
28+ Target DotNetFrameworkUnitTests => _ => _
29+ . Unlisted ( )
30+ . DependsOn ( Compile )
31+ . OnlyWhenDynamic ( ( ) => EnvironmentInfo . IsWin )
32+ . Executes ( ( ) =>
33+ {
34+ var testAssemblies = UnitTestProjects
35+ . SelectMany ( project =>
36+ project . Directory . GlobFiles (
37+ $ "bin/{ ( Configuration == Configuration . Debug ? "Debug" : "Release" ) } /net472 /*.Tests.dll") )
38+ . Select ( p => p . ToString ( ) )
39+ . ToArray ( ) ;
4040
41- Assert . NotEmpty ( testAssemblies . ToList ( ) ) ;
41+ Assert . NotEmpty ( testAssemblies . ToList ( ) ) ;
42+
43+ foreach ( var testAssembly in testAssemblies )
44+ {
45+ var currentDirectory = Path . GetDirectoryName ( testAssembly ) ;
4246
43- Xunit2 ( s => s
44- . SetFramework ( "net48" )
45- . AddTargetAssemblies ( testAssemblies )
46- ) ;
47- } ) ;
47+ NUnitTasks . NUnit3 ( s => s
48+ . SetInputFiles ( testAssemblies )
49+ . SetProcessWorkingDirectory ( currentDirectory )
50+ ) ;
51+ }
52+ } ) ;
4853
49- Target DotNetUnitTests => _ => _
50- . Unlisted ( )
51- . DependsOn ( Compile )
52- . Executes ( ( ) =>
53- {
54- string [ ] excludedFrameworks = [ "net48" , ] ;
55- DotNetTest ( s => s
56- . SetConfiguration ( Configuration )
57- . SetProcessEnvironmentVariable ( "DOTNET_CLI_UI_LANGUAGE" , "en-US" )
58- . EnableNoBuild ( )
59- . SetDataCollector ( "XPlat Code Coverage" )
60- . SetResultsDirectory ( TestResultsDirectory )
61- . CombineWith (
62- UnitTestProjects ,
63- ( settings , project ) => settings
64- . SetProjectFile ( project )
65- . CombineWith (
66- project . GetTargetFrameworks ( ) ? . Except ( excludedFrameworks ) ,
67- ( frameworkSettings , framework ) => frameworkSettings
68- . SetFramework ( framework )
69- . AddLoggers ( $ "trx;LogFileName={ project . Name } _{ framework } .trx")
70- )
71- ) , completeOnFailure : true
72- ) ;
73- } ) ;
74- }
54+ Target DotNetUnitTests => _ => _
55+ . Unlisted ( )
56+ . DependsOn ( Compile )
57+ . Executes ( ( ) =>
58+ {
59+ string [ ] excludedFrameworks = [ "net48" , ] ;
60+ DotNetTest ( s => s
61+ . SetConfiguration ( Configuration )
62+ . SetProcessEnvironmentVariable ( "DOTNET_CLI_UI_LANGUAGE" , "en-US" )
63+ . EnableNoBuild ( )
64+ . SetDataCollector ( "XPlat Code Coverage" )
65+ . SetResultsDirectory ( TestResultsDirectory )
66+ . CombineWith (
67+ UnitTestProjects ,
68+ ( settings , project ) => settings
69+ . SetProjectFile ( project )
70+ . CombineWith (
71+ project . GetTargetFrameworks ( ) ? . Except ( excludedFrameworks ) ,
72+ ( frameworkSettings , framework ) => frameworkSettings
73+ . SetFramework ( framework )
74+ . AddLoggers ( $ "trx;LogFileName={ project . Name } _{ framework } .trx")
75+ )
76+ ) , completeOnFailure : true
77+ ) ;
78+ } ) ;
79+ }
0 commit comments