zoukankan      html  css  js  c++  java
  • 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 {
    	
    }
    

      

  • 相关阅读:
    以正确的方式开源 Python 项目
    如果你喜欢Python 那么你不得不知的几个开源项目
    如何自学 Python(干货合集)
    不老的新丁 Python何以让人着迷
    流行的Python项目汇总
    AccountManager使用教程
    设计模式大全
    ubuntu12.04安装深度音乐播放器和深度影音
    完毕port(CompletionPort)具体解释
    关于jdbc注冊驱动的那点事
  • 原文地址:https://www.cnblogs.com/wmjone/p/9565479.html
Copyright © 2011-2022 走看看