Provide pioneer own AssertJ assertions
See original GitHub issueWhen checking ExcecutionResults
inside a test class for Throwable
s you have to go through the results and filter them. While doing this, already assertions are made that there are such results. Furthermore to avoid repeated codes some assertions were moved into a method inside the test class and were so hided when only looking at the acutal test case.
We also have some private assertThat...
methods in some extension test classes which can be used in other tests so. Moreover there are no good assertThat(results)
methods in the default AssertJ API. So in stream the idea came up to provide some own AssertJ assertion methods, to do something like the following.
// TODO: assertThat(results).hasSingleTestFailedWith(ExtensionConfigurationException.class);
// TODON'T: result.hasThrowable().isInstanceOf().hasMessage()?
results.assertTestFailedWithExtensionConfigurationException();
Another one:
PioneerAnnotationUtilsTests:
private void assertFailedTestHasMessage(ExecutionResults results, String... messages) {
assertThat(results.numberOfFailedTests()).isEqualTo(1);
assertThat(results.firstFailuresThrowableMessage()).isEqualTo(String.join(",", messages));
}
Examples can be seen at this tutorial
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
AssertJ / Fluent assertions for java
Writing your own assertions is simple : create a class inheriting from AbstractAssert and add your custom assertions methods. To be easy to...
Read more >Custom Assertions with AssertJ - Baeldung
In this tutorial, we'll walk through creating custom AssertJ assertions; the AssertJ's basics can be found here.
Read more >Creating specific assertions · assertj/assertj Wiki - GitHub
Creating its own assertions is simple : create a class inheriting from AbstractAssert and add your custom assertions method. To be easy to...
Read more >Testing with AssertJ assertions - Tutorial - Vogella.com
The AssertJ project provides fluent assertion statements for test code written in Java. These assert statements are typically used with Java JUnit tests....
Read more >Project ASSERT | Boston Medical Center
Project ASSERT (Alcohol and Substance Use Services, Education, and Referral to Treatment) provides screening and brief intervention to patients in BMC's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What I meant was: Are there enough assertions that assert a single test to create a whole different interface for those assertions? You don’t really answer that question in your answer (only tangentially).
Edit of shame: I misunderstood what you meant. Of course we could also have the same interface for multiple tests:
Did you mean it like that? If so, you are absolutely right.
well the initial goal is to use it internally, but what if your code and the usage is so beautiful and intuitive that this might even be used in other junit5 extension for assertions 😃 who knows.