Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running JUnit tests in Ant: why fork into separate VM?

Tags:

java

junit

ant

I am relatively new to Ant and JUnit.

From reading the Ant manual and searching on Google and SO, I understand how to fork into a separate VM when running Junit tests, but not why this is a good or bad practice.

So far, I have found these answers:

  • Running a test in a separate VM will isolate tests and prevent each test from being affected by VM-wide system properties
  • Forking also allows new arguments to be passed to the VM using <jvmarg> [EDIT]
  • Running separate VMs can slow down performance time

Is that all there is to it?

like image 676
Lydia Ralph Avatar asked Nov 20 '25 13:11

Lydia Ralph


1 Answers

When you run your unit tests with a forked VM, you can pass new arguments to it. For example, you may need more memory for running your tests than for compiling, you might want to run your tests in a different directory, or maybe pass different java parameters to the new VM. If you look in the Ant manual for the junit task, you can see many of the parameters are ignored if you're not in fork mode.

like image 53
David W. Avatar answered Nov 22 '25 02:11

David W.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!