我已经在互联网上搜索了将近五天,现在正在寻找解决这个问题的方法,但我似乎无法自己找到并修复它,主要是因为我对Maven和PlayN都很新,所以我不完全确定我到底在想什么.但是,它显然在建立核心时嘶嘶作响.似乎它无法下载"神器过滤器",并且无法运行Surefire的测试.但是,我只是在猜测我不太了解的事情,尽管我一直在努力研究这些事情,就像疯了一样.非常非常感谢来自更有经验的人的任何帮助.我对此失去了理智.
[INFO] Building Synthesis Core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ synthesis-core ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ synthesis-core ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] skip non existing resourceDirectory C:\Users\Josiah\synthesis\core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3:compile (default-compile) @ synthesis-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ synthesis-core ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to …Run Code Online (Sandbox Code Playgroud) 我用JUnit 5编写了一个简单的测试方法:
public class SimlpeTest {
@Test
@DisplayName("Some description")
void methodName() {
// Testing logic for subject under test
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时mvn test,我得到了:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running SimlpeTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)
不知何故,surefire没有认出那个测试类.我pom.xml看起来像:
<properties>
<java.version>1.8</java.version>
<junit.version>5.0.0-SNAPSHOT</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases> …Run Code Online (Sandbox Code Playgroud) 我需要根据maven-jar-plugin documentation => http://maven.apache.org/plugins/maven-jar-plugin/usage.html中的这个建议将一些src/test/java移动到src/main/java
我之所以这样做,是因为我在测试范围内的另一个项目中使用了测试(辅助)类.
所以我创建了my-project-test,移动了测试类,并配置了surefire以指定测试类directory =>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testSourceDirectory>${basedir}\src\main\java\</testSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
但是当我启动mvn test时,执行了0次测试=>
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)
问题与此相同=> Maven没有找到JUnit测试运行但解决方案(配置surefire maven插件)对我不起作用.
据我所知,测试文件的位置是正确的.
当我运行"mvn test"时,它会找到四个名为SomethingTest的类(它们位于'test'文件夹中).
但是,它忽略了任何jUnit测试(jUnit 4,用@Test注释).
我该如何调试?
编辑 - 这可能与包含的错误版本的jUnit有关.我在运行"mvn -X"时看到了这个
[DEBUG] Retrieving parent-POM: org.codehaus.plexus:plexus:pom:1.0.4 for project: org.codehaus.plexus:plexus-containers:pom:1.0.3 from the repository.
[DEBUG] org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:runtime (selected for runtime)
[DEBUG] junit:junit:jar:3.8.1:runtime (selected for runtime)
[DEBUG] org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.4.1)
[DEBUG] classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
Run Code Online (Sandbox Code Playgroud)
尽管我在root pom中的第一个依赖项是在jUnit 4.8.1上,但由于某些原因,包含了jUnit 3.8.1.
编辑2 - 好吧,这似乎不是答案.Test Classpath包含正确的jUnit(4)和我的测试类.
编辑3 - 我有名为SomethingTester的测试类.当我把它改成SomethingTest时,它起作用了.我检查了Surefire的包含模式,实际上它没有配置为捕获Something Tester.卫生署.
您好我正在尝试使用Maven运行JUnit测试.
public final class CreateAllObject {
public static final String INIT_URL = new String("http://fpt2:8080/webTest/");
@BeforeClass
public static void initialisation()
{
Driver driver = new Driver(PROFILE_PATH);
driver.getDriver().get(INIT_URL);
driver.getDriver().findElement(By.xpath(ADMIN_ARM_XPATH)).click();
BASE_URL = driver.getDriver().getCurrentUrl();
driver.getDriver().close();
try {
new File("C://logfiles//").mkdirs();
log_work = new BufferedWriter (new FileWriter(
new File("C://logfiles//" +
new SimpleDateFormat("dd.MM.yyyy 'at' HH-mm-ss").format(
new GregorianCalendar().getTime())+".log_work")));
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void test()
{
Driver driver = new Driver( PROFILE_PATH );
...
}
@AfterClass
public static void destruction()
{
try
{ …Run Code Online (Sandbox Code Playgroud) 我有一个多模块项目,用maven组织和构建.它由一个war-module,一个ejb-module和一个ear-module组成.他们拥有相同的父项目(用于依赖管理).结构如下:
| - parent(包装pom)
| - ejb-module
| - war-module
| - ear-module
Built order is first ejb-module then war-module than ear-module. The project depends on arquillian for testing. Both ejb-module and war-module contain a test. When I run "mvn clean test -Parq-wildfly-managed" (profile is to activate testing) the test of ejb-module is executed, but the test of war-module is not executed and there is no surefire-report in the target folder. There is no additional information on the output. I …
@SelectPackages 和 @SelectClasses 标签没有被 maven 测试命令解析。虽然它在 IDE 中工作正常。即使我尝试在 pom.xml 中使用标签。
这是代码片段:
package xyz.howtoprogram.junit5.payment;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
public class PaymentServiceTest {
@Test
public void doPaymentZeroAmount() {
assertEquals(1, 1);
}
}
Run Code Online (Sandbox Code Playgroud)
@RunWith(JUnitPlatform.class)
@SelectPackages("xyz.howtoprogram.junit5.payment")
public class UserFeatureSuiteTest {
}
Run Code Online (Sandbox Code Playgroud)
它没有运行包下的任何测试用例。尽管它下面有一个测试用例。
xyz.howtoprogram.junit5.payment -> PaymentServiceTest.java
Running xyz.howtoprogram.junit5.suite.UserFeatureSuiteTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec - in xyz.howtoprogram.junit5.suite.UserFeatureSuiteTest.
Run Code Online (Sandbox Code Playgroud)
即使我尝试更改 pom.xml,例如添加“包含”标签。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> …Run Code Online (Sandbox Code Playgroud)