0

我抛出了一个错误,我在 testng 阅读中尝试了多个选项,有人可以告诉我在 xml 上设置目标或执行的正确方法,还是这是由于 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>
4

1 回答 1

0

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

于 2013-07-19T08:42:07.463 回答