-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain_test.go
57 lines (46 loc) · 1.38 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
)
func TestResultsExportedWhenExecutionFails(t *testing.T) {
// Arrange
result := testResult{}
mi := mockInterrupt{testResult: &result}
ir = mi
parser = mockParser{}
setupFailingUnitTestsExecutor(ir, &result)
// Act
main()
// Assert
assert.Equal(t, true, result.testResultsExported)
assert.Equal(t, true, result.coverageExported)
assert.Equal(t, "", result.failedMessage)
assert.Equal(t, true, result.stepFailed)
}
func TestCoverageExportedWhenExecutionFails(t *testing.T) {
// Arrange
result := testResult{}
mi := mockInterrupt{testResult: &result}
ir = mi
parser = mockParser{}
setupFailingUnitTestsExecutor(ir, &result)
// Act
main()
// Assert
assert.Equal(t, false, result.testExecuted)
assert.Equal(t, true, result.testResultsExported)
assert.Equal(t, true, result.coverageExported)
assert.Equal(t, "", result.failedMessage)
assert.Equal(t, true, result.stepFailed)
}
func TestResultsAreExportedFromNonRootProject(t *testing.T) {
// Arrange
result := testResult{}
test := testWrapperExecutor{realTestExecutor: realTestExecutor{testExporter: mockTestExporter{testResult: &result}}, realExport: true}
// Act
test.exportTestResults(config{ProjectLocation: testProjectLocation}, bytes.Buffer{})
// Assert
assert.Equal(t, result.exportPath, testProjectLocation+"/"+testResultFileName)
}