question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide pioneer own AssertJ assertions

See original GitHub issue

When checking ExcecutionResults inside a test class for Throwables 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Michael1993commented, Apr 29, 2020

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:

assertThat(results).hasNumberOfTests(2).thatStarted().thatFailed();

Did you mean it like that? If so, you are absolutely right.

0reactions
aepflicommented, Apr 29, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found