@@ -7,70 +7,66 @@ export def "test handles when spec does not exist" [] {
7
7
}
8
8
9
9
export def "test exit with error when test errors" [] {
10
- let specScript = "
11
- export module test {
12
- export def test_that_fails [] { exit 400 }
13
- }
14
- "
10
+ use tests/test-spec-that-errs .nu "verify json results"
11
+ let specFile = " tests/test-spec-that-errs.nu"
12
+
15
13
do {
16
- ^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name " test " -- test-spec-module-script $specScript
14
+ ^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile
17
15
}
18
16
| complete
19
17
| assert not equal 0 ($in.exit_code )
20
18
}
21
19
22
- export def "test handles when no tests" [] {
23
- let specScript = "
24
- export module test {
25
- }
26
- use test *
27
- "
28
- (^$nu.current-exe --no-config-file nuunit.nu
29
- --test-spec-module-name " test"
30
- --test-spec-module-script $specScript
31
- --as-json )
20
+ export def "test when there are no tests everything still works" [] {
21
+ use tests/test-spec-with-zero-tests .nu "verify json results"
22
+ let specFile = " tests/test-spec-with-zero-tests.nu"
23
+
24
+ (^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
32
25
| from json
33
- | length
34
- | assert equal 0 $in
26
+ | verify json results
35
27
}
36
28
37
- export def "test runs tests from spec script" [] {
38
- let specScript = "
39
- export module test {
40
- export def test_the_stuff [] {}
41
- export def test_the_other [] {}
42
- }
43
- use test *
44
- "
45
- (^$nu.current-exe --no-config-file nuunit.nu
46
- --test-spec-module-name " test"
47
- --test-spec-module-script $specScript
48
- --as-json )
29
+ export def "test when there is one test everything still works" [] {
30
+ use tests/test-spec-with-one-test .nu "verify json results"
31
+ let specFile = " tests/test-spec-with-one-test.nu"
32
+
33
+ (^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
34
+ | from json
35
+ | verify json results
36
+ }
37
+
38
+ export def "test when there are two tests everything still works" [] {
39
+ use tests/test-spec-with-two-tests .nu "verify json results"
40
+ let specFile = " tests/test-spec-with-two-tests.nu"
41
+
42
+ (^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
49
43
| from json
50
- | length
51
- | assert equal 2 $in
44
+ | verify json results
52
45
}
53
46
54
47
export def "test when test errors runner keeps chugging" [] {
55
- let specScript = "
56
- export module test {
57
- export def test_the_stuff [] {}
58
- }
59
- use test *
60
- "
61
- (^$nu.current-exe --no-config-file nuunit.nu
62
- --test-spec-module-name " test"
63
- --test-spec-module-script $specScript
64
- --as-json )
65
- | print
48
+ use tests/test-spec-that-errs .nu "verify json results"
49
+ let specFile = " tests/test-spec-that-errs.nu"
50
+
51
+ (^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
52
+ | from json
53
+ | verify json results
66
54
}
67
55
68
- export def "not starting with test means the command will not run" [] {
69
- " why would you run this?"
70
- exit 1
56
+ export def "test when exported command does not match pattern it is not included" [] {
57
+ use tests/test-spec-with-exported-commands-that-are-not-tests .nu "verify json results"
58
+ let specFile = " tests/test-spec-with-exported-commands-that-are-not-tests.nu"
59
+
60
+ (^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
61
+ | from json
62
+ | verify json results
71
63
}
72
64
73
- def "test private commands are not magically ran" [] {
74
- " why would you run this?"
75
- exit 1
65
+ export def "test private commands that look likes tests are not included" [] {
66
+ use tests/test-spec-with-private-commands-that-look-like-tests .nu "verify json results"
67
+ let specFile = " tests/test-spec-with-private-commands-that-look-like-tests.nu"
68
+
69
+ (^$nu.current-exe --no-config-file nuunit.nu -- test-spec-module-name $specFile -- as-json )
70
+ | from json
71
+ | verify json results
76
72
}
0 commit comments