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

FlatSpec examples using mixin-stacking / "withFixture" test setup are incorrect #74

Open
simlei opened this issue Oct 5, 2017 · 0 comments
Assignees

Comments

@simlei
Copy link

simlei commented Oct 5, 2017

On page http://www.scalatest.org/user_guide/sharing_fixtures#composingFixtures
(in section Composing fixtures by stacking traits)

The tutorial code does not compile.

trait Builder extends SuiteMixin { this: Suite =>

  val builder = new StringBuilder

  abstract override def withFixture(test: NoArgTest) = {
    builder.append("ScalaTest is ")
    try super.withFixture(test) // To be stackable, must call super.withFixture
    finally builder.clear()
  }
}
[...]

Errors:

[error] /home/simon/atomWorkspace/scala/scalabc/sub/ui/src/test/scala/scalabc/ui/UiTest.scala:17: not found: type NoArgTest
[error]   abstract override def withFixture(test: NoArgTest) = {
[error]                                           ^
[error] /home/simon/atomWorkspace/scala/scalabc/sub/ui/src/test/scala/scalabc/ui/UiTest.scala:19: value withFixture is not a member of org.scalatest.SuiteMixin
[error]     try super.withFixture(test) // To be stackable, must call super.withFixture
[error]               ^
[error] /home/simon/atomWorkspace/scala/scalabc/sub/ui/src/test/scala/scalabc/ui/UiTest.scala:28: not found: type NoArgTest
[error]   abstract override def withFixture(test: NoArgTest) = {
[error]                                           ^
[error] /home/simon/atomWorkspace/scala/scalabc/sub/ui/src/test/scala/scalabc/ui/UiTest.scala:29: value withFixture is not a member of org.scalatest.SuiteMixin

Solution:
http://www.scalatest.org/release_notes/3.0.0 states that you have to use TestSuiteXYZ everywhere

i.e. replace SuiteMixin with TestSuiteMixin, Suite with TestSuite.

Nontrivial to find the solution by googling, breaks

"Testing" should "be easy"
[...]
it should "be fun" in {
  beginToLearnScalatest()
}

Great website nonetheless! Quite good cheat sheets too!

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

2 participants