本文整理匯總了Java中org.junit.runner.Description.getMethodName方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.getMethodName方法的具體用法?Java Description.getMethodName怎麽用?Java Description.getMethodName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.runner.Description
的用法示例。
在下文中一共展示了Description.getMethodName方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: map
import org.junit.runner.Description; //導入方法依賴的package包/類
private void map(Description source, Description parent) {
for (Description child : source.getChildren()) {
Description mappedChild;
if (child.getMethodName() != null) {
mappedChild = Description.createSuiteDescription(String.format("%s [%s](%s)", child.getMethodName(), getDisplayName(), child.getClassName()));
parent.addChild(mappedChild);
if (!isTestEnabled(new TestDescriptionBackedTestDetails(source, child))) {
disabledTests.add(child);
} else {
enabledTests.add(child);
}
} else {
mappedChild = Description.createSuiteDescription(child.getClassName());
}
descriptionTranslations.put(child, mappedChild);
map(child, parent);
}
}
示例2: testFinished
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public void testFinished(final Description description) throws Exception {
if (!Objects.equals(lastMethodName, description.getMethodName())) {
lastMethodName = description.getMethodName();
printSuccessful("SUCCESSFUL");
println(simplifyMethodName(lastMethodName));
}
}
示例3: appendAllOpts
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public ReproduceErrorMessageBuilder appendAllOpts(Description description) {
super.appendAllOpts(description);
if (description.getMethodName() != null) {
//prints out the raw method description instead of methodName(description) which filters out the parameters
super.appendOpt(SYSPROP_TESTMETHOD(), "\"" + description.getMethodName() + "\"");
}
return appendESProperties();
}
示例4: createTestResult
import org.junit.runner.Description; //導入方法依賴的package包/類
private TestResult createTestResult(final String uuid, final Description description) {
final String className = description.getClassName();
final String methodName = description.getMethodName();
final String name = Objects.nonNull(methodName) ? methodName : className;
final String fullName = Objects.nonNull(methodName) ? String.format("%s.%s", className, methodName) : className;
final String suite = Optional.ofNullable(description.getTestClass().getAnnotation(DisplayName.class))
.map(DisplayName::value).orElse(className);
final TestResult testResult = new TestResult()
.withUuid(uuid)
.withHistoryId(getHistoryId(description))
.withName(name)
.withFullName(fullName)
.withLinks(getLinks(description))
.withLabels(
new Label().withName("package").withValue(getPackage(description.getTestClass())),
new Label().withName("testClass").withValue(className),
new Label().withName("testMethod").withValue(name),
new Label().withName("suite").withValue(suite),
new Label().withName("host").withValue(getHostName()),
new Label().withName("thread").withValue(getThreadName())
);
testResult.getLabels().addAll(getLabels(description));
getDisplayName(description).ifPresent(testResult::setName);
getDescription(description).ifPresent(testResult::setDescription);
return testResult;
}
示例5: targetRepoPerTestFolder
import org.junit.runner.Description; //導入方法依賴的package包/類
private String targetRepoPerTestFolder(Description description) {
return gitClone.getGitRepoFolder()
+ "_"
+ description.getTestClass().getSimpleName()
+ "_"
+ description.getMethodName();
}
示例6: starting
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
protected void starting(Description description) {
b = Timer.time(desc(description));
logger.info(format("Test starting: %s", desc(description)));
AccessLogFilter accessLogFilter = currentDremioDaemon.getWebServer().getAccessLogFilter();
if (accessLogFilter != null) {
// sanitize method name from test since it could be a parameterized test with random characters (or be really long).
String methodName = description.getMethodName();
methodName = methodName.replaceAll("\\W+", "");
if(methodName.length() > 200){
methodName = methodName.substring(0, 200);
}
File logFile = new File(format("target/test-access_logs/%s-%s.log", description.getClassName(), methodName));
File parent = logFile.getParentFile();
if ((parent.exists() && !parent.isDirectory()) || (!parent.exists() && !parent.mkdirs())) {
throw new RuntimeException("could not create dir " + parent);
}
if (logFile.exists()) {
logFile.delete();
}
try {
logger.info(format("access log at %s", logFile.getAbsolutePath()));
docLog = new PrintWriter(logFile);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
accessLogFilter.startLoggingToFile(docLog);
}
}
示例7: starting
import org.junit.runner.Description; //導入方法依賴的package包/類
/**
* sets test class and method name to build path to file
*
* @param description description of the current test method
*/
@Override
protected void starting(Description description) {
this.testClass = description.getTestClass();
this.methodName = description.getMethodName();
}
示例8: testIgnored
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public void testIgnored(final Description description) throws Exception {
lastMethodName = description.getMethodName();
printWarning("IGNORED ");
println(simplifyMethodName(lastMethodName));
}
示例9: TestRequest
import org.junit.runner.Description; //導入方法依賴的package包/類
public TestRequest(Description description) {
testClass = description.getClassName();
frameworkMethod = description.getMethodName();
}
示例10: testStarted
import org.junit.runner.Description; //導入方法依賴的package包/類
/**
*
* @see org.junit.runner.notification.RunListener#testStarted(org.junit.runner.Description)
*/
@Override
public void testStarted( Description description ) throws Exception {
if (log.isDebugEnabled()) {
log.debug("testStarted(): Called when an atomic test is about to be started. Description generally class and method: "
+ description); //, new Exception( "debugging trace" ) );
}
lastStartedMethodIsFailing = false;
Class<?> testClass = description.getTestClass(); //testResult.getTestClass().getRealClass();
String suiteName;
String suiteSimpleName;
String tcName = getTestName(description);
// Update last started method. Note that testStarted() is invoked even before @Before methods
lastStartedMethod = description.getMethodName(); // TODO: check for overridden methods
String tcDescription = getTestDescription(description);
suiteName = testClass.getName(); // assuming not JUnit 3 class "TestSuite"
suiteSimpleName = testClass.getSimpleName();
// check if we need to start a new group
if (!suiteName.equals(lastSuiteName)) {
if (lastSuiteName != null) {
logger.endSuite();
}
String packName = suiteName.substring(0, suiteName.lastIndexOf('.'));
logger.startSuite(packName, suiteSimpleName);
lastSuiteName = suiteName;
}
// start a scenario and test case
logger.startTestcase(suiteName, suiteSimpleName, tcName, "", tcDescription);
// send TestStart event to all ATS agents
TestcaseStateEventsDispacher.getInstance().onTestStart();
logger.info("[JUnit]: Starting " + suiteName + "@" + tcName);
super.testStarted(description);
}
示例11: desc
import org.junit.runner.Description; //導入方法依賴的package包/類
private String desc(Description description) {
return description.getClassName() + "." + description.getMethodName();
}
示例12: logInfo
import org.junit.runner.Description; //導入方法依賴的package包/類
private static void logInfo(final Description description, final long nanos) {
final String testName = description.getMethodName();
log.info("Test {} {} milliseconds", testName, NANOSECONDS.toMillis(nanos));
}
示例13: getTestName
import org.junit.runner.Description; //導入方法依賴的package包/類
private String getTestName( Description description ) {
return description.getMethodName();
}