Skip to content
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

AssertionFailedError interrupts test tree in Console and Gradle #658

Closed
1 task
smoyer64 opened this issue Feb 17, 2017 · 6 comments
Closed
1 task

AssertionFailedError interrupts test tree in Console and Gradle #658

smoyer64 opened this issue Feb 17, 2017 · 6 comments

Comments

@smoyer64
Copy link
Contributor

smoyer64 commented Feb 17, 2017

Overview

  • (X) Bug report. When assertions fail during a test run and provide a multi-line message (as is common with the Hamcrest assertions and matchers, the test tree is interrupted when running via the console or Gradle. This problem is also seen when assertAll() throws a MultipleFailuresError. The example below demonstrates both these failure conditions:
@Test
public void assertAllExample() {
	assertAll(
		() -> { throw new AssertionError(new Throwable("first thing went wrong")); },
		() -> { throw new AssertionError(new Throwable("second thing went wrong")); },
		() -> assertThat("ERROR! - something is broke", not(containsString("ERROR!")))
	);
}

@Test
public void assertOneExample() {
	assertTrue(false, "Wasn't expecting that!\n\nNow I've broken the tree");
}

The output from when these tests are run via Gradle is as follows:

│  ├─ example.testrule.ErrorCollectorJupiterDemo
│  │  ├─ assertAllExample ✘ Multiple Failures (3 failures)
        java.lang.Throwable: first thing went wrong
        java.lang.Throwable: second thing went wrong
        
Expected: not a string containing "ERROR!"
     but: was "ERROR! - something is broke"
│  │  ├─ assertOneExample ✘ Wasn't expecting that!

Now I've broken the tree

Deliverables

  • Continue the tree structure across line breaks similar to the following:
│  ├─ example.testrule.ErrorCollectorJupiterDemo
│  │  ├─ assertAllExample ✘ Multiple Failures (3 failures)
│  │  │    java.lang.Throwable: first thing went wrong
│  │  │    java.lang.Throwable: second thing went wrong
│  │  │    
│  │  │    Expected: not a string containing "ERROR!"
│  │  │    but: was "ERROR! - something is broke"
│  │  ├─ assertOneExample ✘ Wasn't expecting that!
│  │  │    
│  │  │    Now I've broken the tree
@marcphilipp
Copy link
Member

Thanks for opening the issue! I'm putting it up-for-grabs for now. Do you want to give it a go?

@smoyer64
Copy link
Contributor Author

@marcphilipp ... I'm working on #343 at the moment (could you review what I've proposed) and had also started on #144. Since #343 is still slated for the M4 release I'd like to finish that work before I commit to any further fixes. After that I'd be happy to pick off some of the up-for-grabs (I may need to add the fail() methods in #656 to finish #343 though).

@sormuras sormuras self-assigned this Feb 17, 2017
@sormuras
Copy link
Member

As I'm still mentally inside the tree-rendering topic, I assigned this issue to myself.

@sormuras
Copy link
Member

The VerboseTreePrintingListener already handles the multiline detail message. Will move some of that logic up the hierachy.

sormuras added a commit that referenced this issue Feb 19, 2017
Fixes #658 by handling potential multi-line messages within the
TreePrintingListener. Before this commit, the vertical test tree
tiles were interrupted when a multi-line message was provided.
sormuras added a commit that referenced this issue Feb 19, 2017
Fixes #658 by handling potential multi-line messages within the
TreePrintingListener. Before this commit, the vertical test tree
tiles were interrupted when a multi-line message was provided.
@sormuras
Copy link
Member

@smoyer64 This should be fixed with #667 - can you please verify? Thanks in advance.

@smoyer64
Copy link
Contributor Author

CONFIRMED

I commented out line 30 of the ErrorCollectorJupiterDemo (@extensions.ExpectToFail) and now see the following output when the assertAll() method is executed:

│  ├─ ErrorCollectorJupiterDemo
│  │  ├─ example() ✘ Multiple Failures (3 failures)
│  │  │            java.lang.Throwable: first thing went wrong
│  │  │            java.lang.Throwable: second thing went wrong
│  │  │  
│  │  │      Expected: not a string containing "ERROR!"
│  │  │           but: was "ERROR! - something is broke"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants