结合Junit的预期和超时

时间:2017-07-20 07:17:14

标签: java junit

我正在编写一个函数测试,我想结合预期和超时,我不想让全局超时 喜欢:

@Rule
public Timeout globalTimeout= new Timeout(200);

我的例子:

    @Test(expected = IllegalStateException.class)
    @Test(timeout = 200)
    public void lattesRequireMilk() throws InterruptedException {
        // given
        Cafe cafe = new Cafe();
        cafe.restockBeans(7);

        // when
        cafe.brew(Latte); 
        Thread.sleep(400);
    }

1 个答案:

答案 0 :(得分:0)

哦,我发现对不起我的愚蠢问题:

[
   "1",
   "2",
   "3"
]