Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pom.xml maven中的概要文件_Maven_Selenium_Testng_Pom.xml_Allure - Fatal编程技术网

pom.xml maven中的概要文件

pom.xml maven中的概要文件,maven,selenium,testng,pom.xml,allure,Maven,Selenium,Testng,Pom.xml,Allure,以下是我的pom.xml: <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.comp

以下是我的pom.xml:

    <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>
    </properties>
      <dependencies>
        ... dependencies ...
     </dependencies>

 <profiles> 
        <profile>
            <id>suit1</id>
    <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                  <property>
                        <name>allure.results.directory</name>
                        <value>${project.build.directory}/allure-results</value>
                    </property>
                <argLine>   -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/1.9.1/aspectjweaver-1.9.1.jar" </argLine>
                <suiteXmlFiles>      <suiteXmlFile>src/test/java/Smartphones/suite1.xml</suiteXmlFile>                  </suiteXmlFiles>

            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>1.9.1</version>
                </dependency>
            </dependencies>
        </plugin>
       <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.9</version>
            </plugin>
    </plugins>
    </build>

    </profile>
</profiles> 
</project>

UTF-8
1.8
1.8
... 依赖项。。。
诉讼1
org.apache.maven.plugins
maven编译器插件
1.8
1.8
org.apache.maven.plugins
maven surefire插件
2.20
allure.results.directory
${project.build.directory}/allure结果
-javaagent:“${settings.localRepository}/org/aspectj/aspectjweaver/1.9.1/aspectjweaver-1.9.1.jar”
src/test/java/smartners/suite1.xml
org.aspectj
aspectjweaver
1.9.1
io.qameta.allure
诱惑马文
2.9
我想在这里有很多个人资料。我将在其中哪一个中添加新的suite(number).xml

是否可以只留下以下内容:

<suiteXmlFiles>   
   <suiteXmlFile>
               src/test/java/Smartphones/suite1.xml
    </suiteXmlFile> 
</suiteXmlFiles>

src/test/java/smartners/suite1.xml

在配置文件部分?不要在每个配置文件中复制插件和依赖项?是否可以将此信息移到上面?正确的方法是什么

A
profile
是您在普通的
pom
之上添加的内容,因此您应该只在
profile
中输入您想要更改的内容

在您的情况下,您可以移动
maven编译器插件
,也可以移动主
pom
中的
allure maven
,并仅复制
surefire
设置。 您还可以尝试在主
pom
pluginManagement
部分中移动
surefire
的依赖项

如果由于某种原因,无法在主
pom
中移动这些配置,则可以定义与所有这些配置通用的配置文件,并为每个
suite.xml
添加特定的配置文件

在这种情况下,您需要为每次执行启用两个配置文件,即common和suite。

一切皆有可能

你应该做的是:

  • pom.xml
    的根目录中定义
    部分(不在
    中)
  • 在本节中定义您的
    。不要定义
    ,只需定义
    ,或者如果确实定义了
    ,请确保它不是用于您希望提取到
    的内容(例如,不要将
    部分放在那里)
  • 在您的
    中,定义仅适用于您的
    的不同配置设置
考虑以下示例:

<project ....>
    ...

    <build>
        <pluginManagement>
            <!-- pluginManagement is used to define the configuration
                 of your plugins and then inherit it
                 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <property>
                        <name>allure.results.directory</name>
                        <value>${project.build.directory}/allure-results</value>
                    </property>
                    <argLine>-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/1.9.1/aspectjweaver-1.9.1.jar"</argLine>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>1.9.1</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.9</version>
            </plugin>
        </pluginManagement>
        <plugins>
            <!-- When there is a pluginManagement section like the one above,
                 you can just invoke your plugins like without
                 any further configuration -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles> 
        <profile>
            <!-- So, since you're now inheriting from the
                 pluginManagement section and you've declared that
                 your project uses these plugins, you can now extract
                 the suite configuration in a separate profile like this:
                 -->
            <id>suite1</id>

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

                        <configuration>
                            <suiteXmlFiles>      

       <suiteXmlFile>src/test/java/Smartphones/suite1.xml</suiteXmlFile>                  
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

...
org.apache.maven.plugins
maven编译器插件
1.8
1.8
org.apache.maven.plugins
maven surefire插件
2.20
allure.results.directory
${project.build.directory}/allure结果
-javaagent:“${settings.localRepository}/org/aspectj/aspectjweaver/1.9.1/aspectjweaver-1.9.1.jar”
org.aspectj
aspectjweaver
1.9.1
io.qameta.allure
诱惑马文
2.9
org.apache.maven.plugins
maven编译器插件
org.apache.maven.plugins
maven surefire插件
io.qameta.allure
诱惑马文
套房1
org.apache.maven.plugins
maven surefire插件
src/test/java/smartners/suite1.xml

您需要suite1.xml文件的原因是否充分?通常您将运行所有单元测试?还是我误解了一件事?这样做有效,唯一需要做的就是在
下添加
标记,否则会抛出错误