如何从命令行执行maven项目

时间:2018-01-27 15:55:12

标签: maven command-line

以下是我每次从命令行在项目文件夹上运行MVN TEST时收到的消息。

[INFO] No tests to run.
[INFO] ----------------
[INFO] BUILD SUCCESS

我的Testscripts位置如下。我转到下面的文件夹并从命令行运行mvn test。

/Copy of naukri/src/testScripts/NewTest.java

以下是项目的POM文件

<?xml version="1.0" encoding="UTF-8"?>
<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>naukri</groupId>
    <artifactId>NewTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>NaukriUpdate</name>
    <description>----------------</description>
    <build>
        <sourceDirectory>../src/testScripts/</sourceDirectory>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <testSourceDirectory>../src/testScripts/</testSourceDirectory> 
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>

                    </suiteXmlFiles>
                    <manifest>
                        <mainClass>testScripts.NewTest</mainClass>
                    </manifest>
                </configuration>

            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>

                <configuration>
                    <systemPropertyVariables>
                        <propertyName>firefox</propertyName>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.5.3</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.10</version>     
            <exclusions>
    <exclusion>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
    </exclusion>
  </exclusions>                                                             
       </dependency>
    </dependencies>
</project>

1 个答案:

答案 0 :(得分:1)

中移动您的考试
  

的src /测试/ JAVA

请查看文档https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html