我有一个maven项目,在src / test / java中我有一个带有@Test方法的java文件,它基本上启动了整个测试套件,当我运行TestNG或jUnit时,一切正常。
但是当我通过Maven Test运行时,我得到的信息低于消息并且没有执行任何操作。有人可以帮助我吗?
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for MavenHybridFramework:MavenHybridFramework:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.relevantcodes:extentreports:jar should use a variable instead of a hard-coded path D:\UD\jars\extentreports_Updated.jar @ line 36, column 18
[WARNING] 'dependencies.dependency.systemPath' for org.monte:media:jar should use a variable instead of a hard-coded path D:\UD\jars\MonteScreenRecorder.jar @ line 43, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenHybridFramework 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenHybridFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ MavenHybridFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenHybridFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ MavenHybridFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenHybridFramework ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.491 s
[INFO] Finished at: 2015-09-23T09:35:28+05:30
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------
以下是我的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>
<groupId>MavenHybridFramework</groupId>
<artifactId>MavenHybridFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>1.41</version>
<scope>system</scope>
<systemPath>D:\UD\jars\extentreports_Updated.jar</systemPath>
</dependency>
<dependency>
<groupId>org.monte</groupId>
<artifactId>media</artifactId>
<version>0.7.7</version>
<scope>system</scope>
<systemPath>D:\UD\jars\MonteScreenRecorder.jar</systemPath>
</dependency>
</dependencies>
</project>
以下是我的TestNG测试
package TestSuite;
import org.testng.annotations.Test;
import FrameworkLibraries.FunctionLibraries.CommonFunctionLibrary;
import FrameworkLibraries.FunctionLibraries.FrameworkFunctionLibrary;
public class AutomationDriver
{
@Test
public void runTestSuite()
{
FrameworkFunctionLibrary frameworkFuncLib=new FrameworkFunctionLibrary();
//The below method initilizes the framework to make sure required configurations exists
frameworkFuncLib.frameworkInit();
//The below loads the required Test Data configurations and execute test cases
frameworkFuncLib.frameworkExecuteTestCases();
}
}
答案 0 :(得分:0)
首先尝试做Maven Clean。 然后尝试执行Maven测试。
此外,Eclipse Maven集成始终不起作用。 尝试从命令提示符/ Shell执行mvn clean install。
这应该有用。
答案 1 :(得分:0)
对于以下错误,
Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_45\..\lib\tools.jar ->
添加:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7.0</version>
<scope>system</scope>
<systemPath> add your path/Java/jdk1.7.0_60/lib/tools.jar</systemPath>
</dependency>
答案 2 :(得分:0)
尝试将以下内容添加到pom.xml中。它应该将编译器版本增强到JDK 1.8。对我来说,它很有效。
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>