开发者

Start multiple instances of program with different parameters

I have some testcases for a program, so i want to start all of them, one after one. I use eclipse as IDE, so it would be great to have the testcases and so on right in there and dont need to write a bash script or so to do t开发者_开发百科his job (i could and did some times)

So is there any possibility that i can start my program with different parameters from eclipse? My program will exit when the testcase is read and processed, then the next programm should start (best would be on the same virtual console, so i can see the output of both)


For test cases, use junit, which is already included in eclipse.

If you want to run you java programm with different parameters, simply call the main method directly. Here's a JUnit 4 snippet:

@Test
public void testMainWithTestCase0001() {
  String[] params = {"-d", "testcase0001"};
  Main.main(params);
  // usually we'd add some asserts but that's difficult
  // if we test a method that does not return a value...
}

@Test
public void testMainWithTestCase0002() {
  String[] params = {"-d", "testcase0002"};
  Main.main(params);
}


May be JUnit can help you this. You can run multiple test cases with different parameters.

For details, you can try to find some tutorial on JUnit.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜