I'm working on a simple compiler for class that takes input from a higher-level language and produces quasi-assembly code that runs on an emulator. I'm trying to set up test cases for the program that compare the expected output of the emulator with the actual output, but I've been having issues since running code on the emulator requires two stages of processing. In stage one I run my compiler and in stage two I run the output code in the emulator (which I run as an external tool in Eclipse by clicking this button: . I've gotten to the point where I can test the output of the compiler (i.e. the assembly language) in JUnit, but I'm not sure how to take that final step to run the emulator from within JUnit.
You could programatically run the emulator using Runtime.exec() from within the body of your test method.
But normally you wouldn't want to resort to something like this. Unit tests should try to test one thing in isolation - your compiler in this case. It sounds like your test cases should consist of the HLL input and expected assembly output; leave the emulator out of it.
Yes, you can run the command which would like to execute in different process using Runtime.exec. you can wait until the process get completed.