简体   繁体   English

有没有办法在两个不同的jvm上运行相同的junit测试

[英]Is there a way to run same junit test on two different jvm

@Test
    public void testMain1() throws Exception {

        Runnable t1 = new Runnable() {
            public void run() {
                String[] str1 = {"noproxyconfig/serverA.dat"};
                try {
                    SIMLConcentratorMain.main(str1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };

        Runnable t2 = new Runnable() {
            public void run() {
                String[] str2 = {"noproxyconfig/serverB.dat"};
                try {
                    SIMLConcentratorMain.main(str2);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        };
        new Thread(t1).start();
        new Thread(t2).start();
        TimeUnit.SECONDS.sleep(5);
}

Basically I am trying to start main method two times with different arguments (which is starting two servers) . 基本上,我尝试使用不同的参数两次启动main方法(这将启动两个服务器)。 Right now I am achieving this using multithreading but I think its running in same JVM. 现在,我正在使用多线程来实现这一点,但是我认为它可以在同一JVM中运行。 But I want to start both servers in different JVM. 但是我想在不同的JVM中启动两个服务器。 I created Juint test and created two thread and calling both threads. 我创建了Juint测试并创建了两个线程并调用了两个线程。

With Remote Method Invocation (RMI) you can run on two different machine(so two JVM) 使用远程方法调用(RMI),您可以在两台不同的计算机上运行(因此有两个JVM)

you can use virtual machine 你可以使用虚拟机

1-Create Rmi Methode 1-创建Rmi Methode

2-Start servers in many machines 两台机器中的2启动服务器

3-Start your test 3-开始测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM