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

Wrong error message when duplicate test names inside a forAll clause #1385

Open
quiram opened this issue Jun 21, 2018 · 3 comments
Open

Wrong error message when duplicate test names inside a forAll clause #1385

quiram opened this issue Jun 21, 2018 · 3 comments

Comments

@quiram
Copy link

quiram commented Jun 21, 2018

When I use WordSpec and write two tests with the same name like this:

"trying something" should {
    "work as expected" in {}

    "work as expected" in {}
  }

I get the expected error:

[info]   org.scalatest.exceptions.DuplicateTestNameException was thrown inside "trying something" should, construction cannot continue: "Duplicate test name: trying something should work as expected"

However, if the duplicated entry is inside a forAll clause, like the following:

"trying something" should {
    val scenarios = Table("value", "first", "first")
    
    forAll(scenarios) { value =>
      s"work as expected for $value " in {
      }
    } 
  }

I am still going to have duplicate tests, since the value of $value is the same in both cases, but the error message is the rather confusing:

[info]   Assertion should be put inside it or they clause, not should, must, when, that, which or can clause.

It would be clearer if the error message could refer to the fact that the values in the Table are leading to duplicate test names.

@dhirendra31pandit
Copy link

I am also having same issue with AnyFunSuite with nested test("TestName")

@rahulahoop
Copy link

wow spent 1.5 hrs on this today ! ! please fix this error message.

@cheeseng
Copy link
Contributor

Fyi I submitted the following PR for this:

#2132

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

No branches or pull requests

4 participants