• java Junit自动化测试框架环境搭建


    junit自动化测试框架

    junit框架搭建需要的jar包

      hamcrest-core-1.3.jar

      junit-4.12.jar

    package test;
    
    import org.junit.After;
    import org.junit.AfterClass;
    import org.junit.Before;
    import org.junit.BeforeClass;
    import org.junit.Ignore;
    import org.junit.Test;
    
    
    public class Test1 {
    	
    	@AfterClass
    	public static void testAfterClass() {
    		System.out.println("----------AfterClass-------------");
    	}
    	
    	@BeforeClass
    	public static void testBeforeClass() {
    		System.out.println("----------BeforeClass-------------");	
    	}
    	
    	
    	@After
    	public void testAfter() {
    		System.out.println("----------After-------------");
    	}
    	
    	@Before
    	public void test2() {
    		System.out.println("----------Before-------------");
    	}
    	
    	@Test
    	public void testADD() {
    		System.out.println("----------add-------------");
    	}
    	
    	@Test
    	public void testDelete() {
    		System.out.println("----------delete-------------");
    	}
    	
    	@Ignore
    	@Test
    	(expected=java.lang.ArithmeticException.class,timeout=100)
    	public void testIngore() {
    		try {
    			Thread.sleep(200);
    		} catch (InterruptedException e) {
    			System.out.println("----------exception-------------"+e.getMessage());	
    		}
    		System.out.println("----------Ignore-------------");	
    	}
    
    }

      

    package test;
    
    import org.junit.Test;
    
    public class Test2 {
    
    	@Test
    	public void test() {
    		System.out.print("-------test2-------");
    	}
    
    }
    

      

    package test;
    
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    import org.junit.runners.Suite.SuiteClasses;
    
    @RunWith(Suite.class)
    @SuiteClasses({Test1.class,Test2.class})
    
    public class TestMain {
    	
    }
    

      

  • 相关阅读:
    个人-GIT使用方法
    结对贪吃蛇游戏-结对编项目设计文档
    结对编程项目作业2-开发环境搭建过程
    团队编程项目作业2-团队编程项目设计文档
    结对编程项目作业5
    课后作业-阅读任务-阅读提问-3
    团队编程项目作业3-模块测试过程
    团队编程项目作业3-模块开发过程
    结对编程项目作业4
    课后作业-团队编程项目进度
  • 原文地址:https://www.cnblogs.com/wmjone/p/9565479.html
Copyright © 2020-2023  润新知