zoukankan      html  css  js  c++  java
  • JUnit实战(2)

    创建Java Project项目:ch02-internals

    MasterTestSuite.java

    package com.manning.junitbook.ch02.internals;
    
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    import org.junit.runners.Suite.SuiteClasses;
    
    @RunWith(value = Suite.class)
    @SuiteClasses(value = { TestSuiteA.class, TestSuiteB.class })
    public class MasterTestSuite {
        
    }

    TestSuiteA.java

    package com.manning.junitbook.ch02.internals;
    
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    import org.junit.runners.Suite.SuiteClasses;
    
    @RunWith(value = Suite.class)
    @SuiteClasses(value = { TestCaseA.class })
    public class TestSuiteA {
        
    }

    TestSuiteB.java

    package com.manning.junitbook.ch02.internals;
    
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    import org.junit.runners.Suite.SuiteClasses;
    
    @RunWith(value = Suite.class)
    @SuiteClasses(value = { TestCaseB.class })
    public class TestSuiteB {
        
    }

    TestCaseA.java

    package com.manning.junitbook.ch02.internals;
    
    import static org.junit.Assert.assertEquals;
    
    import org.junit.Test;
    
    public class TestCaseA {
        @Test
        public void testA1() {
            assertEquals("Dummy test-case", 1+1, 2);
        }
    }

    TestCaseB.java

    package com.manning.junitbook.ch02.internals;
    
    import static org.junit.Assert.assertTrue;
    
    import org.junit.Test;
    
    public class TestCaseB {
        @Test
        public void testB1() {
            assertTrue("Dummy test-case", true);
        }
    }

    注:层级关系Suite-->Suite--TestCase.

    pom.xml

    <?xml version="1.0"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.manning.junitbook</groupId>
            <artifactId>junit-in-action-II</artifactId>
            <version>2.0-SNAPSHOT</version>
        </parent>
        <artifactId>ch02-internals</artifactId>
        
        <packaging>jar</packaging>
    
        <name>JUnitBook Chapter 2 - JUnit internals</name>
        <url>http://maven.apache.org</url>
    </project>
  • 相关阅读:
    学生管理
    数据类型
    Linux安装、发布Django项目
    函数式编程
    学生管理系统
    mysql数据库工具类
    python操作数据库
    链接mysql建库建表
    列表元组字典集合
    内置对象相关方法
  • 原文地址:https://www.cnblogs.com/thlzhf/p/4276038.html
Copyright © 2011-2022 走看看