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>
  • 相关阅读:
    解决IE输入框文本输入时的 X
    CSS3发光输入框
    去掉超链接或按钮点击时出现的虚线边框
    [LeetCode][JavaScript]Add and Search Word
    [LeetCode][JavaScript]Lowest Common Ancestor of a Binary Search Tree
    [LeetCode][JavaScript]Palindrome Linked List
    [LeetCode][JavaScript]Number of Digit One
    [LeetCode][JavaScript]Implement Queue using Stacks
    [LeetCode][JavaScript]Implement Trie (Prefix Tree)
    [LeetCode][JavaScript]Power of Two
  • 原文地址:https://www.cnblogs.com/thlzhf/p/4276038.html
Copyright © 2011-2022 走看看