Maven Arquillian Junit Test не проходит - PullRequest
0 голосов
/ 30 ноября 2018

Я бегу arquillian с junit 4.11, используя maven-surefire-plugin 2.20.1:

ОШИБКА :

[ERROR]   JUnit4Provider.invoke:160->executeTestSet:239->executeWithRerun:275->execute:369 » NoSuchMethod

Stacktrace :

java.lang.NoSuchMethodError: org.junit.runners.model.TestClass.getAnnotatedFields()Ljava/util/List;
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:369)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:275)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:239)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:160)

Тестовый класс

@RunWith(Arquillian.class)
public class GreeterTest {

    @Deployment
    public static JavaArchive createDeployment() {
        JavaArchive jar = ShrinkWrap
                .create(JavaArchive.class)
                .addClasses(Greeter.class, PhraseBuilder.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
        System.out.println(jar.toString());
        return jar;
    }

    @Inject Greeter greeter;

    @Test
    public void should_create_greeting() {
        Assert.assertEquals(
                "Hello, Earthling!",
                greeter.createGreeting("Earthling")
        );
        greeter.greet(System.out, "Earthling");
    }
}

Импорт спецификации Maven

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>1.4.0.Final</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
</dependencyManagement>

Зависимости Maven

<dependency>
  <groupId>org.jboss.arquillian.junit</groupId>
  <artifactId>arquillian-junit-container</artifactId>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.jboss.arquillian.container</groupId>
  <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
  <version>1.0.0.CR9</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.jboss.weld</groupId>
  <artifactId>weld-core</artifactId>
  <version>2.3.5.Final</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.6.4</version>
  <scope>test</scope>
</dependency>

1 Ответ

0 голосов
/ 08 января 2019

Обязательно используйте junit 4.12:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
...