创建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>

 

posted on 2015-02-05 22:00  逝者如斯(乎)  阅读(1252)  评论(1编辑  收藏  举报