上游充通大 JUNIT SHANGHAI JIAO TONG UNIVERSITY For application developers,testing forms an integral part of the development life-cycle. As old code is modified for reasons ranging from adding new functionality to speed optimizations,the risk of dependent functionality getting broken Increases. Tests that are written once,and can be run repeatedly is the only solution to avoid manually QA testing. To write these tests,for applications written in java, JUnit provides a solid framework for writing unit tests.Many JUnit integrations also exist to integrate your JUnit tests into build and development tools
JUNIT For application developers, testing forms an integral part of the development life-cycle. As old code is modified for reasons ranging from adding new functionality to speed optimizations, the risk of dependent functionality getting broken increases. Tests that are written once, and can be run repeatedly is the only solution to avoid manually QA testing. To write these tests, for applications written in java, JUnit provides a solid framework for writing unit tests. Many JUnit integrations also exist to integrate your JUnit tests into build and development tools
上浒充通大学 JUNIT安装 SHANGHAI JIAO TONG UNIVERSITY 1.从htto:/ww.junit.org/index.htm下载JUNT包 JUNIT.JAR ④2.将JAR文件拷贝到JDK的LIB目录, C:\Javaljdk1.5.0\lib. g 3.在CLASSPATH目录下增加一条c:\Javaljdk 1.5.0\lib\junit.jar;
JUNIT安装 1. 从http://www.junit.org/index.htm下载JUNIT包 JUNIT.JAR 2.将JAR文件拷贝到JDK的LIB目录, C:\Java\jdk1.5.0\lib.。 3. 在CLASSPATH 目录下增加一条 c:\Java\jdk 1.5.0\lib\junit.jar;
上游充通大学 在Eclipse中使用JUNIT SHANGHAI JIAO TONG UNIVERSITY 测试对于保证软件开发质量有着非常重要的作用, 单元测试更是必不可少,JUit是一个非常强大的 单元测试包,可以对一个/多个类的单个/多个方 法测试,还可以将不同的TestCase:组合成 TestSuit,使测试任务自动化。Eclipse同样集成 了JUnit,i 可以非常方便地编写TestCase。 我们创建一个Java工程,添加一个 example.Hello类,首先我们给Hello类添加一个 abs0方法,作用是返回绝对值:
在Eclipse中使用JUNIT 测试对于保证软件开发质量有着非常重要的作用, 单元测试更是必不可少,JUnit是一个非常强大的 单元测试包,可以对一个/多个类的单个/多个方 法测试,还可以将不同的TestCase组合成 TestSuit,使测试任务自动化。Eclipse同样集成 了JUnit,可以非常方便地编写TestCase。 我们创建一个Java工程,添加一个 example.Hello类,首先我们给Hello类添加一个 abs()方法,作用是返回绝对值:
上游充通大¥ SHANGHAI JIAO TONG UNIVERSITY DHello.fava 日 1 package example; 2 3public class Hello 4 5 public static void main(String[]args)( 8 9v public int abs(int n)( 1 return n>=0 2 n (-n); 11 1
上游充通大¥ SHANGHAI JIAO TONG UNIVERSITY 下一步,我们准备对这个方法进行测试,确保功能正常。中 Hello.java,右键点击,选择New->JUnit Test Case: Packaoe Explorer x JUnit -☐CrystalBlog 白Hello 白src 白串 example 中-DHello.java JRE Syst Ne型 Project... JUNIT_H classes Open F3 带Package dist Open With docs Class Open Type Hierarchy F4 合b Interface 合report 自Copy Ctrl+C 黑build,.xml Source Folder 自Paste Ctrl+V ☐Jexi Folder ▣petstore Delete Delete File i-☐SendMail Source Alt+Shift+S Refactor Alt+Shift+T JUnit Test Case Import... other... Ctrl+N E☑Export
下一步,我们准备对这个方法进行测试,确保功能正常。中 Hello.java,右键点击,选择New->JUnit Test Case: