java - 使用 Ant 运行 JUnit 批处理文件时出现 "Unable to write log file"错误

标签 java selenium jenkins ant junit

每次我尝试从命令行调用 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/

相关文章:

java - 如果字符是 0 到 8 之间的数字,则将其增加 1(其他字符不变)

testing - 自动化测试 Web 应用程序

java - 如何同步 Jenkins 的构建?

jenkins - Jenkins config.xml 在哪里?以及为什么会出现这个错误呢?

java - 当我们已经使用JDK 1.6时,如何设置JDK 1.5的Path和JAVA-HOME?

java - 在 jackson 中禁用数字到字符串的自动转换

java - DB2 查询似乎挂起

selenium - 我可以使用自定义标签创建 XPath 吗?

javascript - 如何使用 javascript 取消选择 css 样式?

jenkins - 如何在 Jenkins 脚本管道中设置多行参数化 cron 作业?