-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: implement unit testing framework #111
Conversation
👍 |
name: string,required | ||
cases: object[],optional | ||
// if cases is not null | ||
evalute(case):: (object -> CaseResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: evaluate
same 2 lines down
Tests can also be written as functions. e.g. these are valid: local expect = (import "stdlib/truth.jsonnet").expect;
local expectations = (import "stdlib/truth.jsonnet").expectations;
{
"Test test function passing": function()
local a = 1 + 2;
expectations([
expect()
.that(a)
.hasType("number"),
expect()
.that(a)
.isEqualTo(3),
]),
"Test test function failing"():
local a = 1 + 2;
expect()
.that(a)
.isEqualTo(4),
} One huge drawback with this approach is that it's still impossible to test routines that throw exceptions |
This is definitely interesting. In the case of the arith_bools it has more than tripled in size. Ideally there would have been a reduction in size. For the sake of argument, maybe it could look like this:
I also think we should try to use this framework for something more "real". How about your Kubernetes stuff? If not, there is a whole bunch of abstract templates in micromanage we can use. I think there's a big win for unit testing library abstractions (whether mixins or functions) that check that they can be instantiated into either something specific, or at least into something that has a set of expected properties. It would help document their interfaces as well as allowing refactoring with confidence. |
I'll close this for now since this can be easily implemented in a library. |
This pulls in the implementation of substr into native Go instead of interpretted Jsonnet. benchmark old ns/op new ns/op delta Benchmark_Builtin_substr-16 97121527 15115905 -84.44% part of google#111
Implements std.reverse in native Go, improving performance benchmark old ns/op new ns/op delta Benchmark_Builtin_reverse-16 869191619 231309458 -73.39% part of google#111
feat: improve std.base64Decode performance 97%+ Provides a Go-native implementation of std.base64Decode and std.base64DecodeBytes benchmark old ns/op new ns/op delta Benchmark_Builtin_base64Decode-16 10946388307 25004135 -99.77% Benchmark_Builtin_base64DecodeBytes-16 6420742757 181513016 -97.17% related to google#111
Supports tests of type function, and "table tests". Output looks like: