如何减少运行代码的复制资源时间?

时间:2018-07-31 06:53:12

标签: maven automation maven-surefire-plugin

我使用JAVA进行框架编码。复制资源需要花费更多时间来运行代码(将近6至7分钟)。我正在使用maven命令运行代码

  

MVN干净编译测试。

我正在使用pom.xml下面的依赖项管理。

<?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>framework</groupId>
<artifactId>framework</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jre.level>1.8</jre.level>
    <jdk.level>1.8</jdk.level>
</properties>

<build>
    <!-- Source directory configuration -->
    <sourceDirectory>src</sourceDirectory>
    <plugins>


        <!-- Following plugin executes the testng tests -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <printSummary>true</printSummary>
                <!-- Suite testng xml file to consider for test execution -->
                <suiteXmlFiles>

                    <suiteXmlFile>testng.xml</suiteXmlFile>
                    <!-- <suiteXmlFile>testng.xml</suiteXmlFile> -->
                </suiteXmlFiles>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>


    </plugins>
</build>


<dependencies>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.11</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.6.0</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.6</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.16</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.16</version>
    </dependency>

    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>3.1.5</version>
    </dependency>

    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.22.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client-jetty</artifactId>
        <version>1.22.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-drive</artifactId>
        <version>v3-rev72-1.22.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/ru.yandex.qatools.ashot/ashot -->
    <dependency>
        <groupId>ru.yandex.qatools.ashot</groupId>
        <artifactId>ashot</artifactId>
        <version>1.5.3</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/com.github.javafaker/javafaker -->
    <dependency>
        <groupId>com.github.javafaker</groupId>
        <artifactId>javafaker</artifactId>
        <version>0.13</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.github.seratch/jslack -->
    <dependency>
        <groupId>com.github.seratch</groupId>
        <artifactId>jslack</artifactId>
        <version>1.1.2</version>
    </dependency>

</dependencies>
</project>

如何减少执行时间? 请让我知道其他所需信息。

1 个答案:

答案 0 :(得分:0)

如果您进行mvn clean compile test操作,则运行零件要翻倍,等等。仅运行mvn clean test就足够了。此compile阶段包括在内。 在build life cycle documentation中查看更多详细信息。