-
Notifications
You must be signed in to change notification settings - Fork 1
Proposal for a unified testing API for Golo #3
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
Conversation
This proposal presents a simple and unified interface specification for tests (unit, functionals) in Golo, in order to maximize reuse of the individual components.
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.
I like what I read 👍
IMHO, the For me the the language should provide the minimal mechanism to run tests. IMHO, we should
Then the more elaborate APIs, runners, reporters, assertions could be 3rd-party libs. By default, the Thoughts? |
@danielpetisme the extractor is defined by the test framework, not by the user. In the case of your PR eclipse-archived/golo-lang#308, it's the work done in The purpose of the extractor is to abstract this task, as it can be framework specific. For instance, in a framework based on conventions (e.g. execute all public functions named However, the user only use the framework and tells the About the About what is provided by the language, I agree that we can provide a minimal runner and reporter. However, the main purpose of this proposal is to defined minimal API with low coupling. Given the proposed API for the suite and test, we already have the necessary tools to create the suite. Given a provided runner and reporter, a minimal test file can be: module TestFoo
import Foo
function main = |args| {
gololang.testing.Utils.run(list[
["First suite", list[
["sub suite 1", list[
["test that we can create a foo", {
let f = Foo.Foo(42)
require(f oftype Foo.types.Foo.class, "error creating a foo")
}],
["test that a foo has an answer", {
let f = Foo.Foo(42)
require(f: answer() == 42, "error in the answer value")
}]
],
["sub suite 2", list[
["test that is ok", {}],
["test that fails", { throw AssertionError("fails") }]
]
],
["Second suite", list[
["a foo should plop", {
require(Foo.foo() == "plop", "error testing foo")
}],
["a foo should bar for 42", {
require(Foo.bar("answer") == 42, "error testing bar")
}]
]
])
)
} where function run = |suites| {
System.exit(defaultReporter(defaultRunner(suites)))
} However, writing the suite in this way is not really appealing. That's precisely the job of the suite definition and extraction functionalities provided by a test framework 😄 Implementations for a runner and reporter can be quite simple, such as: function defaultRunner = |suites| -> list[
[desc, match {
when isClosure(test) then trying(test)
otherwise defaultRunner(test)
}]
foreach desc, test in tests
]
function defaultReporter = |results| {
var err = 0
foreach desc, result in results {
if result oftype Result.class {
print(desc + " " + result: either(
|v| -> "OK",
|e| -> "FAIL: " + e: message()))
if result: isError() {
err = err + 1
}
} else {
println("# " + desc)
err = err + defaultResult(result)
}
}
return err
}
or use multithreading, futures, lazy evaluation, color the console output, and so on. |
What do we wait to validate the spec? |
This proposal presents a simple and unified interface specification for
tests (unit, functionals) in Golo, in order to maximize reuse of the
individual components.