4
4
using System . IO ;
5
5
using System . Linq ;
6
6
using Coverlet . Tests . Utils ;
7
- using Coverlet . Tests . Xunit . Extensions ;
8
7
using Xunit ;
9
8
using Xunit . Abstractions ;
10
9
@@ -33,9 +32,10 @@ public void DotnetTool()
33
32
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
34
33
UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
35
34
string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
35
+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
36
36
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
37
37
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 ) ;
39
39
if ( ! string . IsNullOrEmpty ( standardError ) )
40
40
{
41
41
_output . WriteLine ( standardError ) ;
@@ -50,75 +50,92 @@ public void StandAlone()
50
50
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
51
51
UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
52
52
string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
53
+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
53
54
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
54
55
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 ) ;
56
57
if ( ! string . IsNullOrEmpty ( standardError ) )
57
58
{
58
59
_output . WriteLine ( standardError ) ;
59
60
}
60
61
Assert . Contains ( "Hello World!" , standardOutput ) ;
62
+ Assert . True ( File . Exists ( outputPath ) ) ;
61
63
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
62
64
}
63
65
64
- [ ConditionalFact ]
65
- [ SkipOnOS ( OS . Linux ) ]
66
- [ SkipOnOS ( OS . MacOS ) ]
66
+ [ Fact ]
67
67
public void StandAloneThreshold ( )
68
68
{
69
69
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
70
70
UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
71
71
string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
72
+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
72
73
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
73
74
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 ) ) ;
75
76
if ( ! string . IsNullOrEmpty ( standardError ) )
76
77
{
77
78
_output . WriteLine ( standardError ) ;
78
79
}
80
+ else
81
+ {
82
+ // make standard output available in trx file
83
+ _output . WriteLine ( standardOutput ) ;
84
+ }
79
85
Assert . Contains ( "Hello World!" , standardOutput ) ;
86
+ Assert . True ( File . Exists ( outputPath ) ) ;
80
87
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
81
88
Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
82
89
Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
83
90
}
84
91
85
- [ ConditionalFact ]
86
- [ SkipOnOS ( OS . Linux ) ]
87
- [ SkipOnOS ( OS . MacOS ) ]
92
+ [ Fact ]
88
93
public void StandAloneThresholdLine ( )
89
94
{
90
95
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
91
96
UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
92
97
string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
98
+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
93
99
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
94
100
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 ) ) ;
96
102
if ( ! string . IsNullOrEmpty ( standardError ) )
97
103
{
98
104
_output . WriteLine ( standardError ) ;
99
105
}
106
+ else
107
+ {
108
+ // make standard output available in trx file
109
+ _output . WriteLine ( standardOutput ) ;
110
+ }
100
111
Assert . Contains ( "Hello World!" , standardOutput ) ;
112
+ Assert . True ( File . Exists ( outputPath ) ) ;
101
113
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
102
114
Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
103
115
Assert . DoesNotContain ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
104
116
}
105
117
106
- [ ConditionalFact ]
107
- [ SkipOnOS ( OS . Linux ) ]
108
- [ SkipOnOS ( OS . MacOS ) ]
118
+ [ Fact ]
109
119
public void StandAloneThresholdLineAndMethod ( )
110
120
{
111
121
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject ( ) ;
112
122
UpdateNugetConfigWithLocalPackageFolder ( clonedTemplateProject . ProjectRootPath ! ) ;
113
123
string coverletToolCommandPath = InstallTool ( clonedTemplateProject . ProjectRootPath ! ) ;
124
+ string outputPath = $ "{ clonedTemplateProject . ProjectRootPath } { Path . DirectorySeparatorChar } coverage.json";
114
125
DotnetCli ( $ "build -f { _buildTargetFramework } { clonedTemplateProject . ProjectRootPath } ", out string standardOutput , out string standardError ) ;
115
126
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 ) ) ;
117
128
if ( ! string . IsNullOrEmpty ( standardError ) )
118
129
{
119
130
_output . WriteLine ( standardError ) ;
120
131
}
132
+ else
133
+ {
134
+ // make standard output available in trx file
135
+ _output . WriteLine ( standardOutput ) ;
136
+ }
121
137
Assert . Contains ( "Hello World!" , standardOutput ) ;
138
+ Assert . True ( File . Exists ( outputPath ) ) ;
122
139
AssertCoverage ( clonedTemplateProject , standardOutput : standardOutput ) ;
123
140
Assert . Contains ( "The minimum line coverage is below the specified 80" , standardOutput ) ;
124
141
Assert . Contains ( "The minimum method coverage is below the specified 80" , standardOutput ) ;
0 commit comments