t.me/atinfo_chat Telegram группа по автоматизации тестирования

How generate html report for selenium test in Eclipse with Junit?


(khris) #1

I want generate junit reports in eclipse. I generated build.xml, than run my test. I perform steps described here http://earlwillis.wordpress.com/2012/01/31/getting-started-with-junit-reports/. But I get error

Buildfile: E:\eclipse\WebDriver\build.xml
build-subprojects:
init:
build-project:
 [echo] WebDriver: E:\eclipse\WebDriver\build.xml
[javac] E:\eclipse\WebDriver\build.xml:45: warning: 'includeantruntime' was not set,     defaulting to build.sysclasspath=last; set to false for repeatable builds
 build:
Sector:
[junit] Running Sector
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] Test Sector FAILED
junitreport:
[junitreport] Processing E:\eclipse\WebDriver\junit\TESTS-TestSuites.xml to E:\DOCUME~1  \CONSUL~1\LOCALS~1\Temp\null35256633
[junitreport] Loading stylesheet jar:file:/E:/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process E:\eclipse\WebDriver\junit\TESTS-TestSuites.xml

BUILD FAILED
E:\eclipse\WebDriver\build.xml:193: Errors while applying transformations: Fatal error during transformation

Total time: 2 seconds

If needed I can provide build.xml. In folder junit I don't see any html files. How should I deal with it?

build.xml (do not find how to attach it in another way)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="WebDriver">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="JUnit 4.libraryclasspath">
        <pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/>
        <pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
    </path>
    <path id="TestNG.libraryclasspath">
        <pathelement location="${ECLIPSE_HOME}/plugins/org.testng.eclipse_6.5.2.20120616_1545/lib/testng.jar"/>
    </path>
    <path id="WebDriver.classpath">
        <pathelement location="bin"/>
        <pathelement location="../selenium-server-standalone-2.23.1.jar"/>
        <path refid="JUnit 4.libraryclasspath"/>
        <path refid="TestNG.libraryclasspath"/>
        <pathelement location="../../Documents and Settings/Consultant/Desktop/Тестування/selenium_test/selenium-2.23.1/selenium-2.23.1/selenium-java-2.23.1.jar"/>
        <pathelement location="../jexcelapi/jxl.jar"/>
        <pathelement location="../poi-3.8/poi-3.8-20120326.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="WebDriver.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="BOMParameter">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="BOMParameter" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="BOMPosition">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="BOMPosition" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Company">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="Company" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="ForTry">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="ForTry" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Last">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.Last" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="pat">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.pat" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Region (1)">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="system.Region" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Region">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="Region" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Salutation">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="system.Salutation" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Sector (1)">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="system.Sector" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Sector">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="Sector" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Task">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="manufacturing_data_management.Task" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Try (1)">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.Try" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="W">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.W" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="WebDriver">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.Last" todir="${junit.output.dir}"/>
            <test name="bobsworld.W" todir="${junit.output.dir}"/>
            <test name="bobsworld.WebTest" todir="${junit.output.dir}"/>
            <test name="bobsworld.Working" todir="${junit.output.dir}"/>
            <test name="business_partner_management.BOMParameter" todir="${junit.output.dir}"/>
            <test name="business_partner_management.BOMPosition" todir="${junit.output.dir}"/>
            <test name="business_partner_management.Company" todir="${junit.output.dir}"/>
            <test name="manufacturing_data_management.Task" todir="${junit.output.dir}"/>
            <test name="system.Region" todir="${junit.output.dir}"/>
            <test name="system.Salutation" todir="${junit.output.dir}"/>
            <test name="system.Sector" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="WebTest (1)">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="WebTest" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="WebTest (2)">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.WebTest" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="Working">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="bobsworld.Working" todir="${junit.output.dir}"/>
            <classpath refid="WebDriver.classpath"/>
        </junit>
    </target>
    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>
</project>
 

 


(Леша) #2

Вас забанили в гугле?

http://stackoverflow.com/questions/10607151/error-the-first-argument-to-the-non-static-java-function-replace-is-not-a-val


(khris) #3

this link is not helpful for me, i tried googling. Ant version is 1.8.2, junit 4, selenium 2.23.1


(Mykhailo Poliarush) #4

прикрепите ваш файл build.xml


(Леша) #5

Из того же топика, ссылка на который приведена выше:

1) After pointing the ANT build to the JDK instead of JRE I was able to get the HTML report. – user1397000

2) If you are using Eclipse/JUnit report with JDK 1.7, please use JDK 1.6. There is a bug in JDK 1.7 with Eclipse/JUnit report similar to what you describe. This may be a similar report: https://netbeans.org/bugzilla/show_bug.cgi?id=201022

Еще очень похожий топик на том же стековерфло: http://stackoverflow.com/questions/10536095/ant-junit-build-error-inside-eclipse

3) My current workaround is to use Java 6 JDK build 31.

 

И вот вам линк к тикету: https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757