What is Junit? Junit is a simple framework to write repeatable tests.It is an instance of the xUnit architecture for unit test frameworks. xUnit 是一套基于测试驱动开发的测试框架
how * 写一个作为测试套件的入口类,这个类里不包含其他的方法 * 更改测试运行器Suite.class * 将要测试类作为数组传入到Suite.SuiteClasses({})
junit parameter setting
更改默认的测试运行器为RunWith(Parameterized.class)
声明变量来存放预期值和结果值
声明一个返回值为Collection的公共静态方法,并使用@Parameters进行修饰
为测试类声明一个带有参数的公共构造函数,并在其中为之声明变量赋值
some examples
public class Calculate {
public int add(int a, int b) {
return a + b;
}
public int substract(int a, int b) {
return a - b;
}
public int multiply(int a, int b) {
return a * b;
}
public int divide(int a, int b) {
return a / b;
}
}
public class CaculateTest {
@Test
public void test() {
fail("Not yet implemented");
}
@Test
public void testAdd() {
assertEquals(6, new Calculate().add(3, 3));
}
@Test
public void testSubstract() {
assertEquals(2, new Calculate().substract(5, 3));
}
@Test
public void testMultiply() {
assertEquals(4, new Calculate().multiply(2, 2));
}
@Test
public void testDivlide() {
assertEquals(4, new Calculate().multiply(2, 2));
}
}
public class CalculateTest2 {
@Test
public void testAdd() {
fail("Not yet implemented");
}
@Test
public void testSubstract() {
fail("Not yet implemented");
}
@Test
public void testMultiply() {
fail("Not yet implemented");
}
@Test
public void testDivide() {
fail("Not yet implemented");
}
}
public class AnotationTest {
@Test
public void testAdd() {
fail("Not yet implemented");
}
@Test
public void testSubstract() {
fail("Not yet implemented");
}
@Test
public void testMultiply() {
fail("Not yet implemented");
}
@Test(expected = ArithmeticException.class)
public void testDivide() {
assertEquals(4, new Calculate().divide(2, 0));
}
@Test(timeout = 2000)
public void testWhile() {
while(true) {
System.out.println("run forever");
}
}
@Ignore
@Test(timeout = 3000)
public void testReadFile() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class ErrorAndFailureTest {
@Test
public void testAdd() {
assertEquals(5, new Calculate().add(3, 3));
}
@Test
public void testSubstract() {
fail("Not yet implemented");
}
@Test
public void testMultiply() {
fail("Not yet implemented");
}
@Test
public void testDivide() {
assertEquals(3, new Calculate().divide(6, 0));
}
}
@RunWith(Parameterized.class)
public class ParameterTest {
int expected = 0;
int input1 = 0;
int input2 = 0;
@Parameters
public static Collection
@RunWith(Suite.class)
@Suite.SuiteClasses({TaskTest1.class, TaskTest2.class, TaskTest3.class})
public class SuiteTest {
}
public class TaskTest1 {
@Test
public void test() {
System.out.println("task test 1");
}
}
public class TaskTest2 {
@Test
public void test() {
System.out.println("task test 2");
}
}
public class TaskTest3 {
@Test
public void test() {
System.out.println("task test 3");
}
}
Traits are a fundamental unit of code reuse in Scala. A trait encapsulates method and field definitions, which can then be reused by mixing them into classes. Unlike class inheritance, in which each c
版本:WebLogic Server 10.3
说明:%DOMAIN_HOME%:指WebLogic Server 域(Domain)目录
例如我的做测试的域的根目录 DOMAIN_HOME=D:/Weblogic/Middleware/user_projects/domains/base_domain
1.为了保证操作安全,备份%DOMAIN_HOME%/security/Defa
http://crazyjvm.iteye.com/blog/1693757 文中提到相关超时问题,但是又出现了一个问题,我把min和max都设置成了180000,但是仍然出现了以下的异常信息:
Client session timed out, have not heard from server in 154339ms for sessionid 0x13a3f7732340003
在Mysql 众多表中查找一个表名或者字段名的 SQL 语句:
方法一:SELECT table_name, column_name from information_schema.columns WHERE column_name LIKE 'Name';
方法二:SELECT column_name from information_schema.colum