Skip to content

Commit ddf4f6f

Browse files
committed
fix: update Readme, logs, output image, and sample script
1 parent 61c26df commit ddf4f6f

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

Readme.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
## Usage
88

99
```fsharp
10+
#load "Sprout.fs"
11+
1012
open Sprout
1113
1214
let suite = describe "A test suite" {
13-
beforeEach {
14-
debug "Before each test"
15-
}
16-
17-
afterEach {
18-
debug "After each test"
19-
}
20-
15+
Info "Top level info message"
2116
it "should pass" {
2217
info "This test passes"
2318
}
@@ -30,6 +25,14 @@ let suite = describe "A test suite" {
3025
pending "This is a pending test"
3126
3227
describe "Nested suite" {
28+
Debug "Use beforeEach and afterEach for setup and teardown"
29+
beforeEach {
30+
debug "Before each test"
31+
}
32+
33+
afterEach {
34+
debug "After each test"
35+
}
3336
it "should also pass" {
3437
info "Nested test passes"
3538
}
@@ -41,23 +44,32 @@ let suite = describe "A test suite" {
4144
let result = 2 + 2
4245
result |> shouldEqual 4
4346
}
47+
}
4448
45-
it "should handle negative numbers" {
46-
let result = -1 + -1
47-
result |> shouldEqual -2
49+
describe "Multiplication" {
50+
it "should multiply two numbers correctly" {
51+
let result = 3 * 3
52+
result |> shouldEqual 9
4853
}
4954
}
55+
}
5056
51-
describe "Faulty Addition" {
52-
it "should fail when adding incorrect numbers" {
53-
let result = 2 + 2
54-
result |> shouldEqual 5
55-
}
57+
describe "Comparisons" {
58+
debug "Testing comparisons"
59+
it "should compare numbers correctly" {
60+
5 > 3 |> shouldBeTrue
5661
}
5762
}
58-
}
5963
60-
runTestSuite suite
64+
describe "Parameterized Tests" {
65+
info "Simply embed test cases and loop over them"
66+
let numbers = [1; 2; 3; 4; 5]
67+
for n in numbers do
68+
it $"should handle number {n}" {
69+
n > 0 |> shouldBeTrue
70+
}
71+
}
72+
}
6173
```
6274

6375
Output:

expected.log

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
 ✅ passed: should pass in Suite 2
77
All tests passed!
88
Summary: 1 passed, 0 failed, 0 pending
9-
Total time: 00:00:00.0045414
9+
Total time: 00:00:00.0046286
1010
A larger test suite
11+
Top level info message
1112
Before each test
1213
This test passes
1314
After each test
@@ -20,6 +21,7 @@ Total time: 00:00:00.0045414
2021
After each test
2122
 ❔ pending: This is a pending test
2223
Nested suite
24+
Use beforeEach and afterEach for setup and teardown
2325
Before each test
2426
Nested test passes
2527
After each test
@@ -40,4 +42,4 @@ There were 2 test failures:
4042
- A larger test suite / should fail - Intentional failure
4143
- A larger test suite / Arithmetic / Faulty Addition / should fail when adding incorrect numbers - Expected 5 but got 4
4244
Summary: 4 passed, 2 failed, 1 pending
43-
Total time: 00:00:00.0034939
45+
Total time: 00:00:00.0036246

out.png

18.5 KB
Loading

sample.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
open Sprout
44

55
let suite = describe "A test suite" {
6+
Info "Top level info message"
67
it "should pass" {
78
info "This test passes"
89
}
@@ -15,7 +16,7 @@ let suite = describe "A test suite" {
1516
pending "This is a pending test"
1617

1718
describe "Nested suite" {
18-
info "Use beforeEach and afterEach for setup and teardown"
19+
Debug "Use beforeEach and afterEach for setup and teardown"
1920
beforeEach {
2021
debug "Before each test"
2122
}

0 commit comments

Comments
 (0)