如何使用IntelliJ为自动化测试用例构建JAR文件

时间:2014-11-20 13:07:07

标签: java maven intellij-idea jar automated-tests

我使用IntelliJ和Maven来自动化测试用例。我想构建JAR文件,以便将其分发给其他人。我有问题,当我运行JAR文件时,它说

  

错误:jarfile无效或损坏

我完成了所有Project Structure设置和Build Artifacts,但仍然收到了该消息。基本上,在src / main中有一个对象类,而在scr / test中有一个测试类。我不知道出了什么问题。我的猜测是清单中的主类???

任何想法都赞赏!

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

<name>Selenium Maven Template</name>
<description>A Maven Template For Selenium</description>
<url>http://www.lazerycode.com</url>

<licenses>
    <license>
        <name>Apache 2</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        <distribution>repo</distribution>
        <comments>A business-friendly OSS license</comments>
    </license>
</licenses>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <env.config>local</env.config>
    <browser>firefox</browser>
    <threads>1</threads>
    <standalone.binary.root.folder>${project.basedir}/src/test/resources/selenium_standalone_binaries</standalone.binary.root.folder>
    <remote>false</remote>
    <seleniumGridURL/>
    <platform/>
    <browserVersion/>
</properties>

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.43.1</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>com.opera</groupId>
                <artifactId>operadriver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.opera</groupId>
        <artifactId>operadriver</artifactId>
        <version>1.5</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.github.detro.ghostdriver</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.1.0</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <id>selenium-tests</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                    <version>2.3.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.7.2</version>
                    <configuration>
                        <parallel>methods</parallel>
                        <threadCount>${threads}</threadCount>
                        <systemProperties>
                            <env.config>${env.config}</env.config>
                            <browser>${browser}</browser>
                            <binaryRootFolder>${standalone.binary.root.folder}</binaryRootFolder>
                            <screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
                            <remoteDriver>${remote}</remoteDriver>
                            <gridURL>${seleniumGridURL}</gridURL>
                            <desiredPlatform>${platform}</desiredPlatform>
                            <desiredBrowserVersion>${browserVersion}</desiredBrowserVersion>
                        </systemProperties>
                        <includes>
                            <include>**/*WebDriver.java</include>
                        </includes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

0 个答案:

没有答案