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

Multi-line string contains output usability #158

Closed
mkobit opened this issue May 3, 2019 · 1 comment
Closed

Multi-line string contains output usability #158

mkobit opened this issue May 3, 2019 · 1 comment
Assignees
Projects
Milestone

Comments

@mkobit
Copy link
Contributor

@mkobit mkobit commented May 3, 2019

Example:

import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Test
import strikt.api.expectThat
import strikt.assertions.contains

internal class Mk {
  companion object {
    private val S = """
      first line
      second line
      third line
    """.trimIndent()
  }
  @Test
  internal fun `assertj contains`() {
    Assertions.assertThat(S)
      .contains("fourth line")
  }

  @Test
  internal fun `strikt contains`() {
    expectThat(S)
      .contains("fourth line")
  }
}

AssertJ output

Expecting:
java.lang.AssertionError: 
Expecting:
 <"first line
second line
third line">
to contain:
 <"fourth line"> 

Strikt output

org.opentest4j.AssertionFailedError: ▼ Expect that "first line second line third line":
  ✗ contains "fourth line" : found "first line second line third line"

I find the AssertJ a bit more readable in that he multi line text is formatted that way in the assertion error output.

Also, in the strikt output the "first line second line third line" piece is duplicated when it might not have to be.

Maybe:

  • Improve subject line to have improved formatting for multi line string contexts
  • Reduce duplication of subject in assertions messages

WDYT?

@robfletcher

This comment has been minimized.

Copy link
Owner

@robfletcher robfletcher commented May 8, 2019

Agreed. This could definitely be better.

@robfletcher robfletcher added this to To do in Release 1.0 via automation May 8, 2019
@robfletcher robfletcher added this to the v1.0 milestone May 8, 2019
@robfletcher robfletcher self-assigned this Dec 1, 2019
Release 1.0 automation moved this from To do to Done Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Release 1.0
  
Done
2 participants
You can’t perform that action at this time.