开发者

generate classes from java test

开发者 https://www.devze.com 2022-12-21 15:24 出处:网络
I wrote a java test and I run it from run as junit test in my project a bin folder was created with \".class\" file

I wrote a java test and I run it from run as junit test in my project a bin folder was created with ".class" file when I wrote a shell to launch the same test(with some modif) by command line it it launches the test without taking account m开发者_如何学Goy modif , do the tests use tha generated .class ? could I remove this ".class" and launch test by command line ? when I launch it by command line,do ".class" generated ? or should I add something to compile test? thanks


When you run the tests from IDE, your project (java source files) is most likely being automatically compiled before the run. If you want to run it from the command line, you need to compile the sources first using javac.


In your script you should add the proper call to javac (the Java compiler) in order to recompile your (source and test) classes, before invoking java (the Java runtime environment) to run your tests. The IDE does this automatically for you.

Provided your test classes are under the test directory, the command to compile your class would look something like this (you may need to add classpath too if you depend on external jars):

javac -sourcepath test *.java -d bin

Here is a reference about the javac parameters on Linux/Solaris, with examples.

0

精彩评论

暂无评论...
验证码 换一张
取 消