Is it possible to use the ScalaTest BDD syntax in a JUnit environment?

Posted by ebruchez on Stack Overflow See other posts from Stack Overflow or by ebruchez
Published on 2011-01-02T20:14:36Z Indexed on 2011/01/02 20:54 UTC
Read the original article Hit count: 210

Filed under:
|

I would like to describe tests in BDD style e.g. with FlatSpec but keep JUnit as a test runner.

The ScalaTest Quick Start does not seem to show any example of this:

http://www.scalatest.org/getting_started_with_junit_4

I first tried naively to write tests within @Test methods, but that doesn't work and the assertion is never tested:

@Test def foobarBDDStyle {
    "The first name control" must "be valid" in {
        assert(isValid("name·1"))
    }
    // etc.
}

Is there any way to achieve this? It would be even better if regular tests can be mixed and matched with BDD-style tests.

© Stack Overflow or respective owner

Related posts about scala

Related posts about scalatest