jeudi 16 avril 2020

JUnit5 Spock 2, @ExtendWith does not work

i am trying to set up testing platform for our new project. We want to use Spock 2 with JUnit 5.

And now i want to use @ExtendWith annotation in Spock based test.

Here is an example:

@SpringBootTest(classes = ExtensionTest.class)
@ExtendWith(ClassExtension.class)
class ExtensionTest extends Specification {

    void "test"() {
        when:
        true

        then:
        noExceptionThrown()
    }
}

Given Extension (ClassExtension.class) is implementing interfaces: BeforeAllCallback and AfterAllCallback.


class ClassExtension implements BeforeAllCallback, AfterAllCallback {

    @Override
    void beforeAll(ExtensionContext extensionContext) throws Exception {
       ...
    }

    @Override
    void afterAll(ExtensionContext extensionContext) throws Exception {
       ...
    }


}

Unfortunately it doesnt't work. Extension is not being run.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire