func ``test It should display correct information when request fails``() {
givenRequestWillFail(withError: "Error")
whenSendingInvoice()
thenShouldDisplayError(withMessage: "Error")
}
Getting rid of test in the beginning of the method name would also be great but probably the subject of an other topic.
Instead of having to allow spaces in function names in order to be able to write more concise tests, I'd rather take a look at e.g. Quick.
Personally, I find describe("it should add two to the given number") { ... } more readable than func ``it should add two to the given number``() { ... }.
Perhaps this can be done via Markdown, this way we can pack a lot more information.
/**
- testDescription: It should display correct information when request fails.
- failBehaviour:
- If it fails with `Error1`, look into class `Foo`
- If it fails with `Error2`, ...
*/
func testUIOnFailRequest() { ... }
And we can have the tester pick up these information rather than using function name.
I believe tests should be self documenting. Using markdown in this way usually leads to developers questioning whether the content of the markdown still holds true. Also, I would say needing that much content is probably a smell that your test should be broken up into smaller chunks anyway.
Not every team is so lucky as to have a separate "tester" - some of us write all of our own tests :)
I am quite fond of how kotlin allows test functions to start and end with a single "`"
fun `ensure function returns true when this condition`() { ... }`
This syntax allows for really easy to read/write tests and takes out any need to markdown or comments. Especially in the context of a test report, having to read through test_functionName_conditions_expectedOutcome() is horrendous by comparison.