本文整理了Java中junit.framework.TestCase.<init>()
方法的一些代码示例,展示了TestCase.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestCase.<init>()
方法的具体详情如下:
包路径:junit.framework.TestCase
类名称:TestCase
方法名:<init>
[英]No-arg constructor to enable serialization. This method is not intended to be used by mere mortals without calling setName().
[中]没有用于启用序列化的参数构造函数。如果不调用setName(),此方法不会被普通人使用。
代码示例来源:origin: google/guava
/**
* Generates a test case verifying that calling any waitForXxx method when not occupying the
* monitor produces an IllegalMonitorStateException.
*/
private static TestCase generateWaitForWhenNotOccupyingTestCase(
final Method method, final boolean fair) {
final boolean timed = isTimed(method); // Not going to bother with all timeouts, just 0ms.
String testName =
method.getName()
+ (fair ? "(fair)" : "(nonfair)")
+ (timed ? "(0ms)" : "()")
+ "/NotOccupying->IMSE";
return new TestCase(testName) {
@Override
protected void runTest() throws Throwable {
Monitor monitor = new Monitor(fair);
FlagGuard guard = new FlagGuard(monitor);
Object[] arguments =
(timed ? new Object[] {guard, 0L, TimeUnit.MILLISECONDS} : new Object[] {guard});
try {
method.invoke(monitor, arguments);
fail("expected IllegalMonitorStateException");
} catch (InvocationTargetException e) {
assertEquals(IllegalMonitorStateException.class, e.getTargetException().getClass());
}
}
};
}
代码示例来源:origin: google/guava
final Method method, final boolean fair1, final boolean fair2) {
final boolean timed = isTimed(method); // Not going to bother with all timeouts, just 0ms.
return new TestCase(method.getName() + (timed ? "(0ms)" : "()") + "/WrongMonitor->IMSE") {
@Override
protected void runTest() throws Throwable {
代码示例来源:origin: org.seasar.kvasir/kvasir-test
protected static Test error(final String message)
{
return new TestCase("error") {
protected void runTest()
{
fail(message);
}
};
}
代码示例来源:origin: stackoverflow.com
// Set is looking for tc2 and finds object with same ref, because of previous set.add(tc2);
System.out.println(set.add(tc2));//fails and gives us false.
// You create new object with new reference.
tc2 = new TestCase(4, 8);
// Yes, because you changed tc2 variable and assigned new reference to it.
System.out.println(set.add(tc2));//succeeds and gives us true?
代码示例来源:origin: stackoverflow.com
public class Grid {
Browser browser = new Browser();
TestCase testCase = new TestCase();
public Grid() {
...
代码示例来源:origin: bcdev/beam
public static Test suite() {
if (isDebugClassTestable()) {
return new TestSuite(DebugTest.class);
} else {
return new TestCase(DebugTest.class.getName()) {
@Override
public void runTest() {
System.out.println(DebugTest.class + ": test will not be performed: Debug.DEBUG == false");
}
};
}
}
代码示例来源:origin: bcdev/beam
public static Test suite() {
if (DDDB.isInstalled()) {
return new TestSuite(DDDBTest.class);
} else {
return new TestCase(DDDBTest.class.getName()) {
@Override
public void runTest() {
System.out.println();
System.out.println(DDDBTest.class + ": warning: test will not be performed: DDDB not installed: ");
System.out.println(DDDB.DB_DIR_PATH);
}
};
}
}
代码示例来源:origin: com.google.guava/guava-tests
/**
* Generates a test case verifying that calling any waitForXxx method when not occupying the
* monitor produces an IllegalMonitorStateException.
*/
private static TestCase generateWaitForWhenNotOccupyingTestCase(final Method method,
final boolean fair) {
final boolean timed = isTimed(method); // Not going to bother with all timeouts, just 0ms.
String testName = method.getName()
+ (fair ? "(fair)" : "(nonfair)")
+ (timed ? "(0ms)" : "()")
+ "/NotOccupying->IMSE";
return new TestCase(testName) {
@Override protected void runTest() throws Throwable {
Monitor monitor = new Monitor(fair);
FlagGuard guard = new FlagGuard(monitor);
Object[] arguments =
(timed ? new Object[] {guard, 0L, TimeUnit.MILLISECONDS} : new Object[] {guard});
try {
method.invoke(monitor, arguments);
fail("expected IllegalMonitorStateException");
} catch (InvocationTargetException e) {
assertEquals(IllegalMonitorStateException.class, e.getTargetException().getClass());
}
}
};
}
代码示例来源:origin: wso2/wso2-synapse
private static void addGenericTests(TestSuite suite, final String processorName,
final Class<? extends TransformerFactory> transformerFactoryClass) {
for (final Class sbf : sourceBuilderFactories) {
for (final Class rbf : resultBuilderFactories) {
String testName = "test" + processorName + shortName(sbf) + shortName(rbf);
suite.addTest(new TestCase(testName) {
@Override
public void runTest() throws Throwable {
String oldTransformerFactory =
TransformerFactory.newInstance().getClass().getName();
System.setProperty(TransformerFactory.class.getName(),
transformerFactoryClass.getName());
test(sbf, rbf);
System.setProperty(TransformerFactory.class.getName(),
oldTransformerFactory);
}
});
}
}
}
代码示例来源:origin: com.google.guava/guava-tests
final boolean fair2) {
final boolean timed = isTimed(method); // Not going to bother with all timeouts, just 0ms.
return new TestCase(method.getName() + (timed ? "(0ms)" : "()") + "/WrongMonitor->IMSE") {
@Override protected void runTest() throws Throwable {
Monitor monitor1 = new Monitor(fair1);
内容来源于网络,如有侵权,请联系作者删除!