Skip to content

Multi-line string contains output usability #158

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

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
Labels
🦄 enhancement New feature or request
Milestone

Comments

@mkobit
Copy link
Contributor

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
Copy link
Owner

Agreed. This could definitely be better.

@robfletcher robfletcher added the 🦄 enhancement New feature or request label May 8, 2019
@robfletcher robfletcher added this to the v1.0 milestone May 8, 2019
@robfletcher robfletcher self-assigned this Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦄 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants