代码之家  ›  专栏  ›  技术社区  ›  Jayan

如何将junit测试分发到另一台机器

  •  2
  • Jayan  · 技术社区  · 14 年前

    将所有jar和任何测试输入文件发送到build\u home(另一台机器)非常简单。如何在新位置运行junit?我应该创建一个小的生成.xml运行测试的文件?(没有办法创造蚂蚁生成.xml(2)有什么解决办法吗?

    (GridGain是可能的解决方案。还没试过。)

    编辑 :Mode详细说明了为什么这更复杂:源代码大约是3G,执行clearcase更新和构建需要相当长的时间(40分钟),而junit测试的实际测试时间是60分钟。我们有许多机器来运行测试——在所有系统上加载Clearcase是不可能的。

    2 回复  |  直到 14 年前
        1
  •  2
  •   JoseK    14 年前

    如果您通过ant使用任务,那么遵循与标准构建相同的原则。您可以从源代码管理中将代码签出到所有目标计算机。

    将所有根目录外部化到内部版本.属性. 这些属性必须像这样在每台机器上设置。

    #Overall Project Name
    project.name=myapp
    
    # Top Level Root directory of the new working project
    toplevel.project.dir=D:/proj/eComm
    
    # Root directory of the source code
    root.project.dir=D:/proj/eComm/Construction
    
    # JDK home directory 
    jdk.home=C:/jdk1.5.0_11
    

    ear.dist.dir = ${root.project.dir}/target
    src.dir     = ${root.project.dir}/src
    test.src.dir = ${root.project.dir}/test
    

    确保您的生成.xml仅通过这些属性引用任何其他子目录,其中没有任何硬编码值。

    我的junit在一个单独的文件中,该文件被导入到生成.xml通过

    <import file="${root.project.dir.buildscripts.dir}/junit.xml"/>
    

    还有一部分junit.xml文件如下所示

    <target name="run.junit" depends="clean.junit, junit.info, prepare.junit"
        description="Compiles and runs all JUnit Tests in the 'test' directory and produces a report of all failures">
    
    <junit printsummary="yes" fork="true" haltonfailure="no" showoutput="yes" maxmemory="512m">
          <jvmarg line="${junit.jvm.arg}"/>
          <classpath>
            <fileset dir="${src.dir}">
              <include name="**/*.*"/>
            </fileset>
            <fileset dir="${ear.dist.dir}/build/classes">
              <include name="**/*.*"/>
            </fileset>
             <pathelement path="${test.run.path}"/>
          </classpath>
          <formatter type="xml"/>
          <batchtest fork="true" todir="${ear.dist.dir}/build/junit">
          <fileset dir="${test.src.dir}" includes="${test.pattern.include}"/>
          </batchtest>
        </junit>
    
    </target>
    
        2
  •  1
  •   duffymo    14 年前

    试试巡航控制。这是一种将构建和单元测试卸载到另一台机器上的好方法。