You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test files must be `.jsonnet` files which manifestize a result of `test.suite` function.
47
+
48
+
```jsonnet
49
+
local test = import "path/to/jsonnetunit/test.jsonnet";
50
+
test.suite({
51
+
})
52
+
```
53
+
2. Add test cases
54
+
55
+
`test.suite` function takes an object which contains fields prefixed with `test`.
56
+
You can add arbitrary number of such fields. `test.suite` does not directly use any other fields.
57
+
58
+
Individual test fields must have at least two fields:
59
+
*`actual` field: There must be a field named `actual`. This is the actual value to be verified.
60
+
* expectation field: There must be another field which describes an expectation. This expectation is used to verify the `actual` value.
61
+
62
+
```jsonnet
63
+
test.suite({
64
+
testFoo: {
65
+
actual: std.length('foo'),
66
+
expect: 3,
67
+
},
68
+
})
69
+
```
70
+
71
+
72
+
The interpretation of the expectation depends on the name of the expectation field. The name `expect` in the example means that it expects that `actual` field is equal to the given value.
When you pass an object, the object must have two fields `actual` and `result`.
99
+
The first field `actual` is overridden with the `actual` value of the test case on evaluation.
100
+
The second field `result` must be an boolean which describes whether `actual` field satisfies your expectation.
101
+
In this case, you can optionally specifies a custom `description` of the expectation. This is used as a part of error message when the test case fails.
0 commit comments