每次我尝试从命令行调用 Ant 构建文件时,我都会收到错误消息:
Unable to write log file
我是不是漏掉了什么?请让我知道,因为我正在尝试使用 Ant 从命令提示符运行我的 Junit 批处理文件。
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntTest" basedir=".">
<description>
AntTest project build file.
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="ExternalLibraries" location="ExternalLibraries"/>
<property name="JenkinsResults" location="Results/JenkinsResults"/>
<property name="TestSuiteName" location="${src}/AntTest.testsuite"/>
<!--Set the classpath for compiling the source files-->
<path id="AntTest.classpath">
<fileset dir="${ExternalLibraries}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${build}"/>
<pathelement location="${Results}"/>
</path>
<!--Set the framework properties required for the run-->
<target name="setFrameworkProperties">
<propertyfile file="framework.properties" >
<entry key="browser" operation="=" value="${Browser}" />
<entry key="url" operation="=" value="${Url}" />
<entry key="Environment" operation="=" value="${Environment}" />
</propertyfile>
</target>
<!--Creates the directory for the classes-->
<target name="createBuildFolder" depends="setFrameworkProperties">
<mkdir dir="${build}"/>
</target>
<!--Creates the Jenkins results folder-->
<target name="createResultsFolder" depends="createBuildFolder">
<mkdir dir="${JenkinsResults}"/>
</target>
<!--Deletes the old build jenkins results files-->
<target name="DeleteContentsOldResultsFolder" depends="createResultsFolder">
<delete>
<fileset dir="${JenkinsResults}">
<include name="**/*.*"/>
</fileset>
</delete>
</target>
<!--Compile the source code from the source folder to the build folder-->
<target name="compile" depends="DeleteContentsOldResultsFolder" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" includeantruntime="false">
<classpath refid="AntTest.classpath" />
</javac>
</target>
<target name="runtestsuite" description="runs a junit testsuite" >
<antcall id="compileTargetCall" description="Call to target compile" target="compile"/>
<!-- runs a testsuite -->
<junit printsummary="yes" haltonfailure="no">
<classpath refid="AntTest.classpath" />
<test name="${TestSuiteName}" haltonfailure="no" todir="${JenkinsResults}">
<formatter type="xml"/>
</test>
</junit>
<antcall id="deleteBuildFolderCall" description="Call to delete build folder" target="deleteBuildFolder" />
</target>
<!--Deletes the directory for the classes after the current run-->
<target name="deleteBuildFolder">
<delete dir="${build}"/>
</target>
</project>
最佳答案
似乎没有太多关于异常的信息打印。在浏览时我来到了现在this这有助于您获得有关异常的更多详细信息。
还有一件事是您是否使用了 log4j 或对它的任何引用。你可以查看this摆脱对 log4j 的引用
谢谢你, 穆拉利
关于java - 使用 Ant 运行 JUnit 批处理文件时出现 "Unable to write log file"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36399975/