| 1 |
/* https://cadence-lang.org/docs/testing-framework |
| 2 |
*/ |
| 3 |
// A `setup` function that always runs before the rest of the test cases. |
| 4 |
// Can be used to initialize things that would be used across the test cases. |
| 5 |
// e.g: initialling a blockchain backend, initializing a contract, etc. |
| 6 |
access(all) |
| 7 |
fun setup() { |
| 8 |
} |
| 9 |
|
| 10 |
// The `beforeEach` function runs before each test case. Can be used to perform |
| 11 |
// some state cleanup before each test case, among other things. |
| 12 |
access(all) |
| 13 |
fun beforeEach() { |
| 14 |
} |
| 15 |
|
| 16 |
// The `afterEach` function runs after each test case. Can be used to perform |
| 17 |
// some state cleanup after each test case, among other things. |
| 18 |
access(all) |
| 19 |
fun afterEach() { |
| 20 |
} |
| 21 |
|
| 22 |
// Valid test functions start with the 'test' prefix. |
| 23 |
access(all) |
| 24 |
fun testSomething() { |
| 25 |
} |
| 26 |
|
| 27 |
access(all) |
| 28 |
fun testAnotherThing() { |
| 29 |
} |
| 30 |
|
| 31 |
access(all) |
| 32 |
fun testMoreThings() { |
| 33 |
} |
| 34 |
|
| 35 |
// Test functions cannot have any arguments or return values. |
| 36 |
access(all) |
| 37 |
fun testInvalidSignature(message: String): Bool { |
| 38 |
} |
| 39 |
|
| 40 |
// A `tearDown` function that always runs at the end of all test cases. |
| 41 |
// e.g: Can be used to stop the blockchain back-end used for tests, etc. or any cleanup. |
| 42 |
access(all) |
| 43 |
fun tearDown() { |
| 44 |
} |
| 45 |
|