运行pom.xml时抛出的错误testng = selenium:无法执行目标

时间:2013-07-18 18:51:57

标签: maven selenium testng pom.xml

我抛出了一个错误,我尝试了在testng读取的多个选项,有人可以告诉我在xml上设置目标或exectuion的正确方法,或者这是由于surfire插件。

用它显示的方式我认为它可能是执行目标上的东西。有些帮助??

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project pams: A type incompatibility occured while executing org.apache.maven.plugins:maven-surefire-plugin:2.15:test: java.io.File cannot be cast to java.lang.Class

[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-surefire-plugin:2.15
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy

这是我一直在使用的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>xxx</groupId>
    <artifactId>xxx</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>xxx</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.15</version>

        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>2.3.0</version>

        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.33.0</version>
        </dependency>
    </dependencies>
    <build>
        <testSourceDirectory>${basedir}/src/test/com</testSourceDirectory>
        <outputDirectory>${basedir}/target/classes</outputDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>selenium-maven-plugin</artifactId>
                    <version>2.3</version>
                    <executions>
                        <execution>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start-server</goal>
                            </goals>
                            <configuration>
                                <background>true</background>
                            </configuration>
                        </execution>
                        <execution>
                            <id>stop-selenium</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop-server</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.15</version>
                    <configuration>
                        <forkCount>3</forkCount>
                        <reuseForks>true</reuseForks>
                        <parallel>methods</parallel>
                        <threadCount>10</threadCount>
                        <suiteXmlFiles>
                        <suiteXmlFile>${basedir}/testng.xml</suiteXmlFile>
                        </suiteXmlFiles>
<!--                        <suiteXmlFiles> -->
<!--                            <suiteXmlFile>${basedir}/testsuite-persistence-layer.xml</suiteXmlFile> -->
<!--                        </suiteXmlFiles> -->
                        <!-- <skipTests>false</skipTests> -->
                        <!-- <systemPropertyVariables> -->
                        <!-- <propertyName>firefox</propertyName> -->
                        <!-- </systemPropertyVariables> -->
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

1 个答案:

答案 0 :(得分:0)

这是肯定的插件:我尝试过你的pom(和一些用于testng.xml的虚拟内容)有同样的问题。当恢复到v2.14时,surefire插件不会抛出此错误并继续进行测试。