Chinaunix首页 | 论坛 | 博客
  • 博客访问: 220930
  • 博文数量: 136
  • 博客积分: 2919
  • 博客等级: 少校
  • 技术积分: 1299
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 09:08
文章分类

全部博文(136)

文章存档

2013年(1)

2011年(135)

我的朋友

分类: Java

2011-03-30 13:50:05

  1. /**
  2.  *
  3.  * edited on Mar 30, 2011 by mht.
  4.   * 14. Is there a basic template I can use to create a test?
  5.   * (Submitted by: Eric Armstrong)
  6.   * The following templates are a good starting point. Copy/paste
  7.   * and edit these templates to suit your coding style.
  8.   * SampleTest is a basic test template:
  9.   */

  10. import org.junit.*;
  11. import static org.junit.Assert.*;

  12. public class SampleTest {

  13.     private java.util.List emptyList;

  14.     /**
  15.      * Sets up the test fixture.
  16.      * (Called before every test case method.)
  17.      */
  18.     @Before
  19.     public void setUp() {
  20.         emptyList = new java.util.ArrayList();
  21.     }

  22.     /**
  23.      * Tears down the test fixture.
  24.      * (Called after every test case method.)
  25.      */
  26.     @After
  27.     public void tearDown() {
  28.         emptyList = null;
  29.     }
  30.     
  31.     @Test
  32.     public void testSomeBehavior() {
  33.         assertEquals("Empty list should have 0 elements", 0, emptyList.size());
  34.     }

  35.     @Test(expected=IndexOutOfBound***ception.class)
  36.     public void testForException() {
  37.         Object o = emptyList.get(0);
  38.     }
  39. }
阅读(395) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~