本文整理了Java中org.testng.annotations.Test.testName()
方法的一些代码示例,展示了Test.testName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Test.testName()
方法的具体详情如下:
包路径:org.testng.annotations.Test
类名称:Test
方法名:testName
暂无
代码示例来源:origin: org.testng/testng
result.setExpectedExceptionsMessageRegExp(test.expectedExceptionsMessageRegExp());
result.setSuiteName(test.suiteName());
result.setTestName(test.testName());
result.setSequential(test.sequential());
result.setSingleThreaded(test.singleThreaded());
代码示例来源:origin: cbeust/testng
result.setExpectedExceptionsMessageRegExp(test.expectedExceptionsMessageRegExp());
result.setSuiteName(test.suiteName());
result.setTestName(test.testName());
result.setSingleThreaded(test.singleThreaded());
result.setRetryAnalyzer(test.retryAnalyzer());
代码示例来源:origin: org.infinispan/infinispan-commons-test
private void checkClassAnnotations(List<String> errors, Set<Class> processedClasses, ITestNGMethod m) {
// Class of the test instance
Class<?> testClass = m.getTestClass().getRealClass();
// Check that the test instance's class matches the XmlTest's support class
// They can be different if a test inherits a @Factory method and doesn't override it
// Ignore multiple classes in the same XmlTest, which can happen when running from the IDE
// or when the testName is incorrect (handled below)
if (m.getXmlTest().getXmlClasses().size() == 1) {
Class xmlClass = m.getXmlTest().getXmlClasses().get(0).getSupportClass();
if (xmlClass != testClass && processedClasses.add(xmlClass)) {
errors.add("Class " + xmlClass.getName() + " must override the @Factory method from base class " +
testClass.getName());
return;
}
}
if (!processedClasses.add(testClass))
return;
// Check that the testName in the @Test annotation is set and matches the test class
// All tests with the same testName or without a testName run in the same XmlTest
// which means they also run in the same thread, not in parallel
Test annotation = testClass.getAnnotation(Test.class);
if (annotation == null || annotation.testName().isEmpty()) {
errors.add("Class " + testClass.getName() + " does not have a testName");
return;
}
if (!annotation.testName().contains(testClass.getSimpleName())) {
errors.add("Class " + testClass.getName() + " has an invalid testName: " + annotation.testName());
}
}
代码示例来源:origin: apache/maven-surefire
private static TestMetadata findTestMetadata( Class<?> testClass )
{
TestMetadata result = new TestMetadata();
if ( HAS_TEST_ANNOTATION_ON_CLASSPATH )
{
Test testAnnotation = findAnnotation( testClass, Test.class );
if ( null != testAnnotation )
{
if ( !StringUtils.isBlank( testAnnotation.suiteName() ) )
{
result.suiteName = testAnnotation.suiteName();
}
if ( !StringUtils.isBlank( testAnnotation.testName() ) )
{
result.testName = testAnnotation.testName();
}
}
}
return result;
}
代码示例来源:origin: org.apache.maven.surefire/surefire-testng
private static TestMetadata findTestMetadata( Class<?> testClass )
{
TestMetadata result = new TestMetadata();
if ( HAS_TEST_ANNOTATION_ON_CLASSPATH )
{
Test testAnnotation = findAnnotation( testClass, Test.class );
if ( null != testAnnotation )
{
if ( !StringUtils.isBlank( testAnnotation.suiteName() ) )
{
result.suiteName = testAnnotation.suiteName();
}
if ( !StringUtils.isBlank( testAnnotation.testName() ) )
{
result.testName = testAnnotation.testName();
}
}
}
return result;
}
代码示例来源:origin: paypal/SeLion
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
try {
if (ListenerManager.isCurrentMethodSkipped(this)) {
logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);
return;
}
Test testMethod = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class);
if (testMethod != null) {
String testName = testMethod.testName();
if (StringUtils.isNotEmpty(testName)) {
testResult.setAttribute(TEST_NAME_KEY, testName);
}
}
} catch (Exception e) { //NOSONAR
logger.log(Level.WARNING, "An error occurred while processing beforeInvocation: " + e.getMessage(), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!