【发布时间】:2020-11-04 07:59:54
【问题描述】:
我需要测试异常但它得到以下错误。
org.testng.TestException:
Method ContactIdentifierHelperTest.test()
[pri:0, instance:se.cambio.contactadministration.contact.helper.ContactIdentifierHelperTest@6d7b4f4c]
should have thrown an exception of type class SpiderException
测试方法:
@Test(expectedExceptions = { SpiderException.class })
public void test() {
ContactData contactData = getContactData();
contactIdentifierHelper.getSpellId(contactData);
}
测试方法:
public String getSpellId(final ContactData contactData)
{
String s = null;
try
{
s = someMethod();
}
catch (SpiderException e)
{
e.printStackTrace();
}
return s;
}
我哪里做错了?
【问题讨论】:
标签: java unit-testing exception testng