谁能在生成Junit报告时帮助我解决以下异常? 我已经为此苦苦挣扎了几天,但仍然不知道如何解决它。
[11:35:15][Step 4/8] [junitreport] java.lang.NullPointerException
[11:35:15][Step 4/8] [junitreport] at gnu.xml.aelfred2.SAXDriver.getLineNumber(SAXDriver.java:1165)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.getLineNumber(Parser.java:1447)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parseTopLevel(Parser.java:1146)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parseExpression(Parser.java:1112)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.VariableBase.parseContents(VariableBase.java:237)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Param.parseContents(Param.java:108)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseOwnChildren(Stylesheet.java:586)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseContents(Stylesheet.java:558)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Parser.java:399)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:483)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:568)
[11:35:15][Step 4/8] [junitreport] at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:974)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.optional.TraXLiaison.readTemplates(TraXLiaison.java:302)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.optional.TraXLiaison.createTransformer(TraXLiaison.java:319)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.optional.TraXLiaison.transform(TraXLiaison.java:180)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:878)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:416)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer.transform(AggregateTransformer.java:271)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator.execute(XMLResultAggregator.java:160)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
[11:35:15][Step 4/8] [junitreport] at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
[11:35:15][Step 4/8] [junitreport] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[11:35:15][Step 4/8] [junitreport] at java.lang.reflect.Method.invoke(Method.java:606)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Task.perform(Task.java:348)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Target.execute(Target.java:435)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Main.runBuild(Main.java:853)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
[11:35:15][Step 4/8] [junitreport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
[11:35:15][Step 4/8] [junitreport] : Error! Could not compile stylesheet
[11:35:15][Step 4/8] [junitreport] : Fatal Error! java.lang.NullPointerException Cause: java.lang.NullPointerException
[11:35:15][Step 4/8] [junitreport] Failed to process /export/lokiagt/BuildAgent/work/710bab37db72c5d1/build/test/result/TESTS-TestSuites.xml
环境:
蚂蚁 --> 1.9.6
JDK --> 1.8.0_171X64
JUNIT --> 4.8.2
下面是我在 ANT 中的单元测试任务:
<target name="unit.test" depends="compile.test.src" description="Run Junit Test">
<echo message="Running Junit Test" />
<junit showoutput="true" printsummary="yes" fork="true" forkmode="once">
<classpath refid="junit.runtime.classpath" />
<sysproperty key="log4j.configuration" value="${test.src.dir}/log4j-unit-test.properties" />
<sysproperty key="javax.xml.transform.TransformerFactory" value="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl" />
<batchtest haltonfailure="no" todir="${test.result.dir}">
<fileset dir="${test.src.dir}">
<include name="**/*Test.java" />
</fileset>
<formatter type="xml" />
</batchtest>
</junit>
<junitreport todir="${test.result.dir}">
<fileset dir="${test.result.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${test.report.dir}" />
</junitreport>
</target>
提前谢谢你!
任何人有任何想法将不胜感激!
最后,在我将 Ant jar 的版本从 1.9.6 降级到 1.7.1 后,它运行良好。需要进一步检查以找到根本原因。