JUnit使用经验

来源:互联网 发布:java接口实例化对象 编辑:程序博客网 时间:2024/06/06 15:53

 

问题:在测试时,仔细验对了BUILD.XML代码,没有问题,可是在运行ANT时,出现unable to locate tools.jar

Expected to find it in d:/xx/java/jre1.6.0_04/lib/tools.jar,导致compile.java任务能执行,compile.test任务也能执行,但是并没有将编译好的class文件放在指定的文件夹中。

解决方法:查看jre1.6的lib确实无法找到tools.jar包,搜索之下发现,该工具包在JDK中,拷贝一份至jre中的lib下,可以正常工作了

 

问题:在执行javac任务时,总是提示warning: 'includeantruntimewas not setdefaulting to build.sysclasspath=lastset to false for repeatable build 

这个问题重不重要?

回答:

Historically, Ant always included its own runtime in the classpath 
made available to the javac task. So any libraries included with Ant, 
and any libraries available to ant, are automatically in your build's 
classpath whether you like it or not

就是设为true时,将自动包含ANT_HOME下的lib中所有类库,设为false将不自动包含,由于JUnit.jar已经被我放置在ANT的lib中,因此,这里需要设置为true

It was decided that this probably wasn't what most people wanted. So 
now there's an option for it. 

> Is it important? 

Yes. It calls your attention to an issue that can make your builds to 
work in unexpected ways. For an example, see item #3 at 
http://blogs.sun.com/kto/entry/painful_ant_bite_a_generous

If you choose "true", then at least you know that your build classpath 
will include the Ant runtime. If you choose "falsethen you are 
accepting the fact that the build behavior will change between older 
versions and 1.8+. 

> Who needs to know? I don't care. 

If you want your build file to have total control over your build
then you should care. 

> Why doesn't Ant just default to false and just omit warning me about this for every Ant build
> I don't want adjust every build file that I have. There are probably other ways, but it's annoying anyhow. 

As annoyed as you are to see this warning, you'd be even less happy if 
your builds broke entirely. Keeping this default behavior allows 
unmodified build files to work consistently between versions of Ant. 

 

问题:在Eclipse中,无法执行build.xml进行测试代码的编译,系统提示package   junit.framework   does   not   exist 

编译任务无法执行

解决:在Windows>>Preference>>Ant>>Runtime>>Classpath中添加junit.jar

原创粉丝点击