File tree Expand file tree Collapse file tree 5 files changed +133
-0
lines changed
Expand file tree Collapse file tree 5 files changed +133
-0
lines changed Original file line number Diff line number Diff line change 5252 with :
5353 dotnet-version : ' 9.0.x'
5454
55+ - name : Setup tools
56+ run : |
57+ npm install -g bats
58+
59+ - name : Tests
60+ env :
61+ DATABASE_HOST : localhost
62+ DATABASE_PORT : 5433
63+ run : |
64+ mkdir test-results
65+ bats . --verbose-run --print-output-on-failure --report-formatter junit --output test-results
66+ ls -lah test-results
67+
5568 - name : Restore dependencies
5669 run : dotnet restore
5770
Original file line number Diff line number Diff line change 11bin
22obj
3+ current.log
4+ test-results
Original file line number Diff line number Diff line change 1+ #load " Sprout.fs"
2+
3+ open Sprout
4+
5+ let s1 = describe " Suite 1" {}
6+ let s2 = describe " Suite 2" {
7+ beforeEach {
8+ debug " Before each test in Suite 2"
9+ }
10+
11+ it " should pass in Suite 2" {
12+ info " This test passes in Suite 2"
13+ }
14+ }
15+ runTestSuite ( describe " Main Suite" { s1; s2 })
16+
17+ let suite = describe " A larger test suite" {
18+ beforeEach {
19+ debug " Before each test"
20+ }
21+
22+ afterEach {
23+ debug " After each test"
24+ }
25+
26+ it " should pass" {
27+ info " This test passes"
28+ }
29+
30+ it " should fail" {
31+ info " This test fails"
32+ failwith " Intentional failure"
33+ }
34+
35+ pending " This is a pending test"
36+
37+ describe " Nested suite" {
38+ it " should also pass" {
39+ info " Nested test passes"
40+ }
41+ }
42+
43+ describe " Arithmetic" {
44+ describe " Addition" {
45+ it " should add two numbers correctly" {
46+ let result = 2 + 2
47+ result |> shouldEqual 4
48+ }
49+
50+ it " should handle negative numbers" {
51+ let result = - 1 + - 1
52+ result |> shouldEqual - 2
53+ }
54+ }
55+
56+ describe " Faulty Addition" {
57+ it " should fail when adding incorrect numbers" {
58+ let result = 2 + 2
59+ result |> shouldEqual 5
60+ }
61+ }
62+ }
63+ }
64+
65+ runTestSuite suite
Original file line number Diff line number Diff line change 1+ [32mMain Suite[0m
2+ [32mSuite 1[0m
3+ [32mSuite 2[0m
4+ [90mBefore each test in Suite 2[0m
5+ [37mThis test passes in Suite 2[0m
6+ [32m ✅ passed: should pass in Suite 2[0m
7+ All tests passed!
8+ Summary: 1 passed, 0 failed, 0 pending
9+ Total time: 00:00:00.0045414
10+ [32mA larger test suite[0m
11+ [90mBefore each test[0m
12+ [37mThis test passes[0m
13+ [90mAfter each test[0m
14+ [32m ✅ passed: should pass[0m
15+ [90mBefore each test[0m
16+ [37mThis test fails[0m
17+ [90mAfter each test[0m
18+ [31m ❌ failed: should fail - Intentional failure[0m
19+ [90mBefore each test[0m
20+ [90mAfter each test[0m
21+ [90m ❔ pending: This is a pending test[0m
22+ [32mNested suite[0m
23+ [90mBefore each test[0m
24+ [37mNested test passes[0m
25+ [90mAfter each test[0m
26+ [32m ✅ passed: should also pass[0m
27+ [32mArithmetic[0m
28+ [32mAddition[0m
29+ [90mBefore each test[0m
30+ [90mAfter each test[0m
31+ [32m ✅ passed: should add two numbers correctly[0m
32+ [90mBefore each test[0m
33+ [90mAfter each test[0m
34+ [32m ✅ passed: should handle negative numbers[0m
35+ [32mFaulty Addition[0m
36+ [90mBefore each test[0m
37+ [90mAfter each test[0m
38+ [31m ❌ failed: should fail when adding incorrect numbers - Expected 5 but got 4[0m
39+ There were 2 test failures:
40+ - [31mA larger test suite / should fail - Intentional failure[0m
41+ - [31mA larger test suite / Arithmetic / Faulty Addition / should fail when adding incorrect numbers - Expected 5 but got 4[0m
42+ Summary: 4 passed, 2 failed, 1 pending
43+ Total time: 00:00:00.0034939
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ @test " Tests.fsx" {
4+ dotnet fsi Tests.fsx > current.log
5+ run diff <( cat expected.log | grep -v " Total time" ) <( cat current.log | grep -v " Total time" )
6+ [ " $status " -eq 0 ]
7+ printf ' Lines:\n'
8+ printf ' lines %s\n' " ${lines[@]} " >&2
9+ printf ' output %s\n' " ${output[@]} " >&2
10+ }
You can’t perform that action at this time.
0 commit comments