本文整理了Java中junit.framework.TestCase.getName()
方法的一些代码示例,展示了TestCase.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestCase.getName()
方法的具体详情如下:
包路径:junit.framework.TestCase
类名称:TestCase
方法名:getName
[英]Gets the name of a TestCase
[中]获取测试用例的名称
代码示例来源:origin: google/guava
/** Returns the name of the test method invoked by this test instance. */
public final String getTestMethodName() {
return super.getName();
}
代码示例来源:origin: junit-team/junit4
private String getName(Test test) {
if (test instanceof TestCase) {
return ((TestCase) test).getName();
} else {
return test.toString();
}
}
代码示例来源:origin: groovy/groovy-core
public String getMethodName() {
return super.getName();
}
代码示例来源:origin: google/j2objc
private String getName(Test test) {
if (test instanceof TestCase) {
return ((TestCase) test).getName();
} else {
return test.toString();
}
}
代码示例来源:origin: google/guava
@Override
public String getName() {
return Platform.format("%s[%s]", super.getName(), suiteName);
}
}
代码示例来源:origin: junit-team/junit4
/**
* Returns a string representation of the test case.
*/
@Override
public String toString() {
return getName() + "(" + getClass().getName() + ")";
}
代码示例来源:origin: google/guava
@Override
public String getName() {
return super.getName() + " [" + suiteName + " [" + caseDesc + "]]";
}
代码示例来源:origin: google/j2objc
/**
* Returns a string representation of the test case
*/
@Override
public String toString() {
return getName() + "(" + getClass().getName() + ")";
}
代码示例来源:origin: junit-team/junit4
/**
* Get the annotations associated with given TestCase.
* @param test the TestCase.
*/
private static Annotation[] getAnnotations(TestCase test) {
try {
Method m = test.getClass().getMethod(test.getName());
return m.getDeclaredAnnotations();
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
}
return new Annotation[0];
}
代码示例来源:origin: groovy/groovy-core
/**
* Overload the getName() method to make the test cases look more like AgileDox
* (thanks to Joe Walnes for this tip!)
*/
public String getName() {
if (useAgileDoxNaming) {
return super.getName().substring(4).replaceAll("([A-Z])", " $1").toLowerCase();
} else {
return super.getName();
}
}
代码示例来源:origin: google/guava
private static Method extractMethod(Test test) {
if (test instanceof AbstractTester) {
AbstractTester<?> tester = (AbstractTester<?>) test;
return Helpers.getMethod(tester.getClass(), tester.getTestMethodName());
} else if (test instanceof TestCase) {
TestCase testCase = (TestCase) test;
return Helpers.getMethod(testCase.getClass(), testCase.getName());
} else {
throw new IllegalArgumentException("unable to extract method from test: not a TestCase.");
}
}
代码示例来源:origin: google/guava
@Override
public String getName() {
return example == null ? super.getName() : buildTestName();
}
代码示例来源:origin: google/guava
private String buildTestName() {
return super.getName() + ":" + example.getName();
}
代码示例来源:origin: google/j2objc
private static Description makeDescription(Test test) {
if (test instanceof TestCase) {
TestCase tc = (TestCase) test;
return Description.createTestDescription(tc.getClass(), tc.getName());
} else if (test instanceof TestSuite) {
TestSuite ts = (TestSuite) test;
String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
Description description = Description.createSuiteDescription(name);
int n = ts.testCount();
for (int i = 0; i < n; i++) {
Description made = makeDescription(ts.testAt(i));
description.addChild(made);
}
return description;
} else if (test instanceof Describable) {
Describable adapter = (Describable) test;
return adapter.getDescription();
} else if (test instanceof TestDecorator) {
TestDecorator decorator = (TestDecorator) test;
return makeDescription(decorator.getTest());
} else {
// This is the best we can do in this case
return Description.createSuiteDescription(test.getClass());
}
}
代码示例来源:origin: junit-team/junit4
private static Description makeDescription(Test test) {
if (test instanceof TestCase) {
TestCase tc = (TestCase) test;
return Description.createTestDescription(tc.getClass(), tc.getName(),
getAnnotations(tc));
} else if (test instanceof TestSuite) {
TestSuite ts = (TestSuite) test;
String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
Description description = Description.createSuiteDescription(name);
int n = ts.testCount();
for (int i = 0; i < n; i++) {
Description made = makeDescription(ts.testAt(i));
description.addChild(made);
}
return description;
} else if (test instanceof Describable) {
Describable adapter = (Describable) test;
return adapter.getDescription();
} else if (test instanceof TestDecorator) {
TestDecorator decorator = (TestDecorator) test;
return makeDescription(decorator.getTest());
} else {
// This is the best we can do in this case
return Description.createSuiteDescription(test.getClass());
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
private String getName(Test test) {
if (test instanceof TestCase) {
return ((TestCase) test).getName();
} else {
return test.toString();
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Returns a string representation of the test case
*/
@Override
public String toString() {
return getName() + "(" + getClass().getName() + ")";
}
代码示例来源:origin: camunda/camunda-bpm-platform
private static Description makeDescription(Test test) {
if (test instanceof TestCase) {
TestCase tc = (TestCase) test;
return Description.createTestDescription(tc.getClass(), tc.getName());
} else if (test instanceof TestSuite) {
TestSuite ts = (TestSuite) test;
String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
Description description = Description.createSuiteDescription(name);
int n = ts.testCount();
for (int i = 0; i < n; i++) {
Description made = makeDescription(ts.testAt(i));
description.addChild(made);
}
return description;
} else if (test instanceof Describable) {
Describable adapter = (Describable) test;
return adapter.getDescription();
} else if (test instanceof TestDecorator) {
TestDecorator decorator = (TestDecorator) test;
return makeDescription(decorator.getTest());
} else {
// This is the best we can do in this case
return Description.createSuiteDescription(test.getClass());
}
}
代码示例来源:origin: apache/jena
@Override
public void startTest(Test test)
{
// Compensate for TestCase.toString() adding "(class)" to the end of the name
String name = "" ;
if ( test instanceof TestCase )
name = ((TestCase)test).getName() ;
else
name = test.toString() ;
System.out.println("Test: "+name) ; }
}
代码示例来源:origin: apache/jena
static private void addTests(TestSuite s, String dir, String base, String file) {
TestCase tc = new StAX2ModelTest(dir, base, file);
tc.setName("StAX " + tc.getName());
s.addTest(tc);
}
final String base;
内容来源于网络,如有侵权,请联系作者删除!