@RunWith(Suite.class)
@Suite.SuiteClasses({AssertTests.class, CalculatorTest.class})
public class SuiteTest {
// the class remains empty, used only as a holder for the above annotations
}
public class AssumptionsTest {
@Test
public void testAssumTrue() {
System.out.println("test");
assumeTrue(3>5);
//该方法中下面所有的代码在上面假设的条件成立后执行
//如果上述假设不成立,则会忽略执行该行下面的代码,并报错
System.out.println("assume is true!");
}
@Test
public void testAssumFalse(){
assumeFalse(3>5);
System.out.println("assume is true!");
}
}
以下语法JUnit5支持:
@Test
public void testAssumTrueMessage() {
assumeTrue(3<5,
//第二个参数为当第一个参数不成立时,输出的自定义错误信息
() -> "Aborting test: not on developer workstation");
System.out.println("assume is true!");
}
@Test
public void testAssumeTrueLambda(){
//这个方法的第一个参数为函数式接口,无参数返回值为boolean
assumeTrue(()->{
System.out.println("in assumeTrue");
boolean flag = false;
return flag;
});
System.out.println("out assumeTrue");
}
@Test
public void testAssumThat() {
assumingThat(3>5,
() -> {
//与上述方法不同的是,仅当前面假设成立时,才会执行这里面的语句
//且只会影响到该lambda表达式中的代码
assertEquals(2, 2);
});
//此处的断言不受上述assumingThat限制,在所有情况下都会执行
System.out.println("no effect");
assertEquals("a string", "a string");
}
@Retention(RetentionPolicy.RUNTIME)
// 声明注解接口所使用的委托处理类
@ParametersSuppliedBy(BetweenSupplier.class)
public @interface Between{
// 声明所有可用参数,效果为 @Between([first = int,] last = int)
int first() default 0; // 声明默认值
int last();
}
(2)定义委托处理类 BetweenSupplier
public class BetweenSupplier extends ParameterSupplier {
@Override
public List getValueSources(ParameterSignature sig) {
// 自定义实参值列表
List list = new ArrayList();
// 获取注解变量
Between between = sig.getAnnotation(Between.class);
// 获取通过注解@Between传入的first值
int first = between.first();
// 获取通过注解@Between传入的last值
int last = between.last();
for (int i = first; i <= last; i++) {
// PotentialAssignment.forValue(String name, Object value)
// name为value的描述标记,没实际作用
// value为实参可选值
list.add(PotentialAssignment.forValue("name", i));
}
return list;
}
}
(3)调用方式
@RunWith(Theories.class)
public class TheoryDefinedTest {
@Theory
public final void test(@Between(last = 0) int i, @Between(first = 3, last= 10) int j) {
// i 取值为 0(first默认=0,last=0),j 取值为 3-10
System.out.println("i="+i+" j="+j);
}
}
public class FixtureTest {
private static int quantity = 0;
public FixtureTest() {
quantity++;
}
@BeforeClass
public static void breforeTestOnlyOnce() throws Exception {
System.out.println("Run before all test only once..."+ quantity);
}
@AfterClass
public static void afterTestOnlyOnce() throws Exception {
System.out.println("Run after all test only once..."+ quantity);
}
@Before
public void beforePerTest() {
System.out.println("Run before per test ..."+ quantity);
}
@After
public void afterPerTest() {
System.out.println("Run after per test ..."+ quantity);
}
//Test Method
@Test
public void testOne() {
System.out.println("testOne Start..."+ quantity);
}
@Test
public void testTwo() {
System.out.println("testTwo Start..."+ quantity);
}
}
运行结果:
Run before all test only once...0
Run before per test ...1
testOne Start...1
Run after per test ...1
Run before per test ...2
testTwo Start...2
Run after per test ...2
Run after all test only once...2
public interface FastTests { /* category marker */ }
public interface SlowTests { /* category marker */ }
public class A {
@Test
public void a() {
fail();
}
@Category(SlowTests.class)
@Test
public void b() {
}
}
@Category({SlowTests.class, FastTests.class})
public class B {
@Test
public void c() {
}
}
@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite
public class SlowTestSuite {
// Will run A.b and B.c, but not A.a
}
@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@ExcludeCategory(FastTests.class)
@SuiteClasses( { A.class, B.class }) // Note that Categories is a kind of Suite
public class SlowTestSuite {
// Will run A.b, but not A.a or B.c
}
#!/bin/bash
address="192.168.150.128:6666,192.168.150.128:6666"
hosts=(${address//,/ })
sfile="staticts.log"
for hostitem in ${hosts[@]}
do
ipport=(${hostitem
提高代码质量的插件1. FindBugsFindBugs可以帮你找到Java代码中的bug,它使用Lesser GNU Public License的自由软件许可。2. CheckstyleCheckstyle插件可以集成到Eclipse IDE中去,能确保Java代码遵循标准代码样式。3. ECLemmaECLemma是一款拥有Eclipse Public License许可的免费工具,它提供了
一、对分组的记录取前N条记录:例如:取每组的前3条最大的记录 1.用子查询: SELECT * FROM tableName a WHERE 3> (SELECT COUNT(*) FROM tableName b WHERE b.id=a.id AND b.cnt>a. cnt) ORDER BY a.id,a.account DE
HTTP(HyperText Transfer Protocol)是一套计算机通过网络进行通信的规则。计算机专家设计出HTTP,使HTTP客户(如Web浏览器)能够从HTTP服务器(Web服务器)请求信息和服务,HTTP目前协议的版本是1.1.HTTP是一种无状态的协议,无状态是指Web浏览器和Web服务器之间不需要建立持久的连接,这意味着当一个客户端向服务器端发出请求,然后We
感谢http://www.w3school.com.cn提供的资料
HTML 文档中的每个成分都是一个节点。
节点
根据 DOM,HTML 文档中的每个成分都是一个节点。
DOM 是这样规定的:
整个文档是一个文档节点
每个 HTML 标签是一个元素节点
包含在 HTML 元素中的文本是文本节点
每一个 HTML 属性是一个属性节点
注释属于注释节点
Node 层次
var formData = new FormData($("#inputFileForm")[0]);
$.ajax({
type:'post',
url:webRoot+"/electronicContractUrl/webapp/uploadfile",
data:formData,
async: false,
ca