栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

jUnit 4中的TestSuite设置

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jUnit 4中的TestSuite设置

这是我所拥有的,运行正常。

import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.runner.RunWith;import org.junit.runners.Suite;import org.junit.runners.Suite.SuiteClasses;@RunWith(Suite.class)@SuiteClasses({ TestSuite1.class, TestSuite2.class })public class CompleteTestSuite {    @BeforeClass     public static void setUpClass() {   System.out.println("Master setup");    }    @AfterClass public static void tearDownClass() {         System.out.println("Master tearDown");    }}

这是我的测试套件1(对测试套件2进行相同的操作)。

import org.junit.runner.RunWith;import org.junit.runners.Suite;import org.junit.runners.Suite.SuiteClasses;@RunWith(value = Suite.class)@SuiteClasses(value = { TestCase1.class })public class TestSuite1 {}

这是我的测试课。同时创建testcase1和testcase2。

import static org.junit.Assert.assertEquals;import org.junit.BeforeClass;import org.junit.Test;public class TestCase1 {    @BeforeClass     public static void setUpClass() {   System.out.println("TestCase1 setup");    }    @Test    public void test1() {        assertEquals(2 , 2);    }}

您应该有5个类completesuite suite1 suite2 test1 test2

并确保在构建路径中有Junit。这应该运行!

这是输出

Master setupTestCase1 setupMaster tearDown


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/595197.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号