Testing Framework API¶
API for writing and running USL tests.
Spec Tests¶
Test Definition¶
spec MyTests {
test "description" {
// test body
assert condition
}
property "property description" {
forall x in Entity {
// property to verify
}
}
}
Assertions¶
assert condition
assert_eq(expected, actual)
assert_ne(expected, actual)
expect_error[ErrorCode] { ... }
Running Tests¶
Generated Tests¶
USL generates unit tests for: - Entity invariants - Policy rules - State transitions - Service actions
TypeScript¶
import { runTests } from '@usl-lang/testing';
describe('UserService', () => {
it('should create user', async () => {
const user = await createUser('test@example.com');
expect(user.email).toBe('test@example.com');
});
});