本文整理了Java中junit.framework.TestCase.fail()
方法的一些代码示例,展示了TestCase.fail()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestCase.fail()
方法的具体详情如下:
包路径:junit.framework.TestCase
类名称:TestCase
方法名:fail
[英]Fails a test with no message.
[中]测试失败,没有消息。
代码示例来源:origin: google/guava
public static void assertMapEntryIsUnmodifiable(Entry<?, ?> entry) {
try {
entry.setValue(null);
fail("setValue on unmodifiable Map.Entry succeeded");
} catch (UnsupportedOperationException expected) {
}
}
代码示例来源:origin: google/guava
/**
* Verifies that an Iterator is unmodifiable.
*
* <p>This test only works with iterators that iterate over a finite set.
*/
public static void assertIteratorIsUnmodifiable(Iterator<?> iterator) {
while (iterator.hasNext()) {
iterator.next();
try {
iterator.remove();
fail("Remove on unmodifiable iterator succeeded");
} catch (UnsupportedOperationException expected) {
}
}
}
代码示例来源:origin: google/guava
@Override
protected void doStop() {
fail();
}
}
代码示例来源:origin: google/guava
@Override
protected void doStop() {
fail();
}
}
代码示例来源:origin: google/guava
@Override
protected void doStop() {
fail();
}
}
代码示例来源:origin: google/guava
@Override
protected void doStop() {
fail();
}
}
代码示例来源:origin: google/guava
@Override
public void onSuccess(String result) {
fail("Was not expecting onSuccess() to be called.");
}
代码示例来源:origin: google/guava
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
// if a buffer isn't being cleared correctly, this method will eventually start being called
// with a len of 0 forever
if (len <= 0) {
fail("read called with a len of " + len);
}
// read fewer than the max number of chars to read
// shouldn't be a problem unless the buffer is shrinking each call
return in.read(cbuf, off, Math.max(len - 1024, 0));
}
};
代码示例来源:origin: google/guava
@Override
public void run() {
lock.lock();
try {
locked.countDown();
finishLatch.await(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
fail(e.toString());
} finally {
lock.unlock();
}
}
代码示例来源:origin: google/guava
@Override
public Integer computeNext() {
if (alreadyCalledEndOfData) {
fail("Should not have been invoked again");
}
alreadyCalledEndOfData = true;
return endOfData();
}
};
代码示例来源:origin: google/guava
@Override
public Integer computeNext() {
if (haveBeenCalled) {
fail("Should not have been called again");
} else {
haveBeenCalled = true;
sneakyThrow(new SomeCheckedException());
}
return null; // never reached
}
};
代码示例来源:origin: google/guava
@Override
public Integer apply(Integer from) {
if (++calls > 1) {
fail();
}
throw new MyRuntimeException();
}
};
代码示例来源:origin: google/guava
void check() {
try {
runTester();
} catch (AssertionFailedError expected) {
return;
}
fail("Should have failed because enum has no constant");
}
}
代码示例来源:origin: google/guava
@Override
public Integer computeNext() {
if (haveBeenCalled) {
fail("Should not have been called again");
} else {
haveBeenCalled = true;
sneakyThrow(new SomeCheckedException());
}
return null; // never reached
}
};
代码示例来源:origin: google/guava
@Override
public void run() {
try {
service.awaitTerminated();
fail("Expected an IllegalStateException");
} catch (Throwable t) {
exception.set(t);
}
}
};
代码示例来源:origin: google/guava
@Override
public Integer apply(Integer from) {
if (++calls > 1) {
fail();
}
throw new MyError();
}
};
代码示例来源:origin: google/guava
@Override
public Integer computeNext() {
switch (rep++) {
case 0:
return 0;
case 1:
return 1;
case 2:
return endOfData();
default:
fail("Should not have been invoked again");
return null;
}
}
};
代码示例来源:origin: google/guava
@Override
public Integer computeNext() {
switch (rep++) {
case 0:
return 0;
case 1:
return 1;
case 2:
return endOfData();
default:
fail("Should not have been invoked again");
return null;
}
}
};
代码示例来源:origin: google/guava
@Override
public Integer computeNext() {
switch (rep++) {
case 0:
return 0;
case 1:
return 1;
case 2:
return endOfData();
default:
fail("Should not have been invoked again");
return null;
}
}
};
代码示例来源:origin: google/guava
void check() {
runTester();
NullRejectingFromTo<?, ?> defaultFunction =
(NullRejectingFromTo<?, ?>) getDefaultParameterValue(0);
assertNotNull(defaultFunction);
try {
defaultFunction.apply(null);
fail("Proxy Should have rejected null");
} catch (NullPointerException expected) {
}
}
}
内容来源于网络,如有侵权,请联系作者删除!