提交 4abe432a 编写于 作者: M Mars Liu

add junit

上级 1e36b6f5
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
以下程序是关于反射的一个例子,程序的控制台打印为: 以下程序是关于反射的一个例子,程序的控制台打印为:
```java ```java
public class Reflect { public class Reflect {
public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
...@@ -20,6 +21,7 @@ public class Reflect { ...@@ -20,6 +21,7 @@ public class Reflect {
### before ### before
```java ```java
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
以下程序是关于动态代理的一个例子,1和2处填入正确的是: 以下程序是关于动态代理的一个例子,1和2处填入正确的是:
```java ```java
interface Person { interface Person {
...@@ -33,7 +34,7 @@ public class DynamicProxyTest { ...@@ -33,7 +34,7 @@ public class DynamicProxyTest {
## 答案 ## 答案
``` ```java
Person.class.getClassLoader() Person.class.getClassLoader()
new Class[] { Person.class } new Class[] { Person.class }
``` ```
...@@ -42,21 +43,21 @@ new Class[] { Person.class } ...@@ -42,21 +43,21 @@ new Class[] { Person.class }
### A ### A
``` ```java
Person.getClassLoader() Person.getClassLoader()
Person.class Person.class
``` ```
### B ### B
``` ```java
Person.class.getClassLoader() Person.class.getClassLoader()
Person.getClass() Person.getClass()
``` ```
### C ### C
``` ```java
Person.getClassLoader() Person.getClassLoader()
new Class[] { Person.class } new Class[] { Person.class }
``` ```
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
下列关于Collection功能方法的说法错误的是: 下列关于Collection功能方法的说法错误的是:
## 答案 ## 答案
``` ```
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
下列关于 `List` 功能方法的说法正确的是: 下列关于 `List` 功能方法的说法正确的是:
## 答案 ## 答案
``` ```
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
下列关于 `Set` 说法正确的是: 下列关于 `Set` 说法正确的是:
## 答案 ## 答案
``` ```
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
下列代码用优先级队列实现了任务队列,运行程序控制台输出正确的是: 下列代码用优先级队列实现了任务队列,运行程序控制台输出正确的是:
```java ```java
class Task { class Task {
private String name; private String name;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
下列关于Collections的实用方法,说法正确的是: 下列关于Collections的实用方法,说法正确的是:
## 答案 ## 答案
``` ```
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
下列关于 `Annotation` 的说法错误的是: 下列关于 `Annotation` 的说法错误的是:
## 答案 ## 答案
``` ```
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
下列关于 `APT(Annotation Processing Tool)` 的说法正确的是: 下列关于 `APT(Annotation Processing Tool)` 的说法正确的是:
## 答案 ## 答案
``` ```
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
"type": "code_options", "type": "code_options",
"author": "ccat", "author": "ccat",
"source": "junit.md", "source": "junit.md",
"notebook_enable": true "notebook_enable": false
} }
\ No newline at end of file
# junit
下列单元测试代码,会被忽略的是:
## 答案
```java
@Ignore
@Test
public void simpleCrlf() throws Throwable {
State<Character> state = newState("\r\n");
Parsec<Character, String> crlf = new Crlf();
String re = crlf.parse(state);
Assert.assertEquals(re, "\r\n");
}
```
## 选项
### A
```java
@Test
public void simpleCrlf() throws Throwable {
State<Character> state = newState("\r\n");
Parsec<Character, String> crlf = new Crlf();
String re = crlf.parse(state);
Assert.assertEquals(re, "\r\n");
}
```
### B
```java
@AfterClass
static public void close(){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
```
### C
```java
@BeforeClass
static public void connect() {
try {
// create a connection to the database
conn = DriverManager.getConnection(url);
System.out.println("Connection to SQLite has been established.");
conn.prepareStatement("create table test(id integer primary key autoincrement, content text)")
.execute();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
```
### D
```java
@Test
public void zooCleanTest(){
Statement statement = delete().from(table);
try{
statement.execute(conn);
Assert.assertTrue(true);
} catch (SQLException|IllegalStateException e) {
Assert.fail(e.getMessage());
}
}
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册