蚂蚁找不到符号@测试 [英] ant-cannot find symbol@Test

查看:77
本文介绍了蚂蚁找不到符号@测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译仅包含一个函数的以下类.

I am trying to compile following class that has just the one function in it.

公共类TestAnnotations {

public class TestAnnotations {

@Test
public void testLogin(){
    System.out.println("Testing Login");
}

当我以JUNIt运行文件时,它可以工作,但是当我尝试从build.xml运行文件时,出现以下错误:找不到符号@Test.我确实在正确的位置具有Junit.jar文件.这是我的build.xml脚本:

When I run the file as JUNIt it works but when I try to run the file from build.xml it gives me the following error: cannot find symbol @Test. I do have the Junit.jar file at the right location. Here is my build.xml script:

    <property environment = "env"/>

    <property name="ws.home" value="${basedir}" />

    <property name="ws.jars" value="D:/Data/eclipse/workspace/SeleniumDemo/lib/oracle_junit/junit.jar"/>
    <property name="test.dest" value="${ws.home}/build" />
    <property name="test.src" value="${ws.home}/src" />
    <property name="test.reportDir" value="C:/reports"/>

    <path id="testcase.path">
        <pathelement location="${test.dest}" />
        <fileset dir="${ws.jars}">
            <include name="*.jar" />
        </fileset>
    </path>

    <target name="init">
            <mkdir dir="build/classes" />           
    </target>

    <target name="clean">
        <delete dir="${test.dest}" />
    </target>

    <target name="compile" depends = "init, clean">
        <delete includeemptydirs= "true" quiet="true">
            <fileset dir = "${test.dest}" includes = "**/*"/>
        </delete>
        <mkdir dir = "${test.dest}"/>
        <javac 
            debug = "true"              
            destdir = "${test.dest}"
            includeantruntime = "false"
            srcdir = "${test.src}"
            target = "1.7"
            classpath = "${test.classpath}"
        >
        </javac>

    </target>


    <target name="run">     
        <fileset dir="${test.dest}">

            <include name="tests/TestAnnotations.class" />

        </fileset>

    </target>

ant成功构建了项目,但是在编译时却失败了

ant builds the project successfully but it fails at compilation

推荐答案

您可能需要将jUnit库添加到类路径中,以便Ant知道它在哪里?

You might need to add the jUnit library to the classpath so Ant knows where it is?

...
<classpath path="path/to/your/junit.jar"/>
...

这篇关于蚂蚁找不到符号@测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆