44using System . IO ;
55using System . Linq ;
66using Coverlet . Tests . Utils ;
7- using Coverlet . Tests . Xunit . Extensions ;
87using Xunit ;
98using Xunit . Abstractions ;
109
@@ -33,9 +32,10 @@ public void DotnetTool()
3332 using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
3433 UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
3534 string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
35+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
3636 DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
3737 string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
38- RunCommand ( coverletToolCommandPath , $ "\" { publishedTestFile } \" --target \" dotnet\" --targetargs \" test { Path . Combine ( clonedTemplateProject . ProjectRootPath , ClonedTemplateProject . ProjectFileName ) } --no-build\" --include-test-assembly --output \" { clonedTemplateProject . ProjectRootPath } \" { Path . DirectorySeparatorChar } ", out standardOutput , out standardError ) ;
38+ RunCommand ( coverletToolCommandPath , $ "\" { publishedTestFile } \" --target \" dotnet\" --targetargs \" test { Path . Combine ( clonedTemplateProject . ProjectRootPath , ClonedTemplateProject . ProjectFileName ) } --no-build\" --include-test-assembly --output \" { outputPath } \" ", out standardOutput , out standardError ) ;
3939 if ( ! string . IsNullOrEmpty ( standardError ) )
4040 {
4141 _output . WriteLine ( standardError ) ;
@@ -50,75 +50,92 @@ public void StandAlone()
5050 using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
5151 UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
5252 string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
53+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
5354 DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
5455 string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
55- RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --output \" { clonedTemplateProject . ProjectRootPath } \" { Path . DirectorySeparatorChar } ", out standardOutput , out standardError ) ;
56+ RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --output \" { outputPath } \" ", out standardOutput , out standardError ) ;
5657 if ( ! string . IsNullOrEmpty ( standardError ) )
5758 {
5859 _output . WriteLine ( standardError ) ;
5960 }
6061 Assert . Contains ( "Hello World!" , standardOutput ) ;
62+ Assert . True ( File . Exists ( outputPath ) ) ;
6163 AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
6264 }
6365
64- [ ConditionalFact ]
65- [ SkipOnOS ( OS . Linux ) ]
66- [ SkipOnOS ( OS . MacOS ) ]
66+ [ Fact ]
6767 public void StandAloneThreshold ( )
6868 {
6969 using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
7070 UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
7171 string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
72+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
7273 DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
7374 string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
74- Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --output \" { clonedTemplateProject . ProjectRootPath } \" \\ ", out standardOutput , out standardError ) ) ;
75+ Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --output \" { outputPath } \" ", out standardOutput , out standardError ) ) ;
7576 if ( ! string . IsNullOrEmpty ( standardError ) )
7677 {
7778 _output . WriteLine ( standardError ) ;
7879 }
80+ else
81+ {
82+ // make standard output available in trx file
83+ _output . WriteLine ( standardOutput ) ;
84+ }
7985 Assert . Contains ( "Hello World!" , standardOutput ) ;
86+ Assert . True ( File . Exists ( outputPath ) ) ;
8087 AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
8188 Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
8289 Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
8390 }
8491
85- [ ConditionalFact ]
86- [ SkipOnOS ( OS . Linux ) ]
87- [ SkipOnOS ( OS . MacOS ) ]
92+ [ Fact ]
8893 public void StandAloneThresholdLine ( )
8994 {
9095 using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
9196 UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
9297 string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
98+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
9399 DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
94100 string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
95- Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --output \" { clonedTemplateProject . ProjectRootPath } \" \\ ", out standardOutput , out standardError ) ) ;
101+ Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --output \" { outputPath } \" ", out standardOutput , out standardError ) ) ;
96102 if ( ! string . IsNullOrEmpty ( standardError ) )
97103 {
98104 _output . WriteLine ( standardError ) ;
99105 }
106+ else
107+ {
108+ // make standard output available in trx file
109+ _output . WriteLine ( standardOutput ) ;
110+ }
100111 Assert . Contains ( "Hello World!" , standardOutput ) ;
112+ Assert . True ( File . Exists ( outputPath ) ) ;
101113 AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
102114 Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
103115 Assert . DoesNotContain ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
104116 }
105117
106- [ ConditionalFact ]
107- [ SkipOnOS ( OS . Linux ) ]
108- [ SkipOnOS ( OS . MacOS ) ]
118+ [ Fact ]
109119 public void StandAloneThresholdLineAndMethod ( )
110120 {
111121 using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
112122 UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
113123 string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
124+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
114125 DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
115126 string publishedTestFile = clonedTemplateProject . GetFiles ( "*" + ClonedTemplateProject . AssemblyName + ".dll" ) . Single ( f => ! f . Contains ( "obj" ) && ! f . Contains ( "ref" ) ) ;
116- Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --threshold-type method --output \" { clonedTemplateProject . ProjectRootPath } \" \\ ", out standardOutput , out standardError ) ) ;
127+ Assert . False ( RunCommand ( coverletToolCommandPath , $ "\" { Path . GetDirectoryName ( publishedTestFile ) } \" --target \" dotnet\" --targetargs \" { publishedTestFile } \" --threshold 80 --threshold-type line --threshold-type method --output \" { outputPath } \" ", out standardOutput , out standardError ) ) ;
117128 if ( ! string . IsNullOrEmpty ( standardError ) )
118129 {
119130 _output . WriteLine ( standardError ) ;
120131 }
132+ else
133+ {
134+ // make standard output available in trx file
135+ _output . WriteLine ( standardOutput ) ;
136+ }
121137 Assert . Contains ( "Hello World!" , standardOutput ) ;
138+ Assert . True ( File . Exists ( outputPath ) ) ;
122139 AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
123140 Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
124141 Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
0 commit comments