2018-01-26 testng的使用技巧

本文仅介绍着三种testng的使用技巧,详细了解可参考testclass的系列文章

http://www.testclass.net/testng/

 /** 该条用例跳过执行**/

@Test(enabled = false)   

publicvoidtestCase1(){

       assertEquals(2+2, 4);   

        }

/** * expectedExceptions 用来预设用例运行会出现的异常。 * 例如 2⁄0 将会抛出 RuntimeException 类型的异常, * 如果出现异常则表示用例执行成功/

@Test(expectedExceptions = RuntimeException.class)

public void testcase() {

        AssertJUnit.assertEquals(4/0, 2+2);

        }

// 设定用例超时时间

@Test(timeOut = 3000)

public void testCase2() throws InterruptedException {

    Thread.sleep(3001);

    }

你可能感兴趣的:(2018-01-26 testng的使用技巧)