【发布时间】:2019-10-25 20:01:46
【问题描述】:
我正在尝试使用工件 maven-plugin-testing-harness:3.3.0 对 Maven 插件的 Mojo 运行单元测试,并具有以下依赖项。但是当我尝试“lookupEmptyMojo”时,会抛出以下异常。 有什么快速解决这个配置问题的方法吗?
...
<properties>
<maven.api.version>3.6.2</maven.api.version>
<dependencies>
<!-- Maven plugin deps -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven.api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.api.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
...
例外:
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.repository.RepositorySystem
roleHint:
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
...
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.util.NoSuchElementException
at org.eclipse.sisu.inject.LocatedBeans$Itr.next(LocatedBeans.java:141)
... 28 more
【问题讨论】:
标签: java maven unit-testing maven-plugin