51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 5268|回复: 8
打印 上一主题 下一主题

请教eclipse下Junit使用

[复制链接]

该用户从未签到

1#
发表于 2012-2-24 10:58:09 | 显示全部楼层
代码片段
  1. public static App app = null;

  2.         /**
  3.          * @throws java.lang.Exception
  4.          */
  5.         @BeforeClass
  6.         public static void setUpBeforeClass() throws Exception {
  7.                 app = new App();
  8.         }

  9.         /**
  10.          * @throws java.lang.Exception
  11.          */
  12.         @AfterClass
  13.         public static void tearDownAfterClass() throws Exception {
  14.                 app = null;
  15.         }

  16.         /**
  17.          * @throws java.lang.Exception
  18.          */
  19.         @Before
  20.         public void setUp() throws Exception {
  21.         }

  22.         /**
  23.          * @throws java.lang.Exception
  24.          */
  25.         @After
  26.         public void tearDown() throws Exception {
  27.         }

  28.         /**
  29.          * Test method for {@link org.biview.testgroup.App#compare1()}.
  30.          */
  31.         @Test
  32.         public void testCompare1() {
  33.                 assertTrue(app.compare1());
  34.         }
复制代码
如果通过maven进行管理的话,直接配置进去就Ok了

  1.                 <dependency>
  2.                         <groupId>junit</groupId>
  3.                         <artifactId>junit</artifactId>
  4.                         <version>4.10</version>
  5.                         <scope>test</scope>
  6.                 </dependency>
复制代码
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-5-13 00:50 , Processed in 0.061395 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表