1 Design, construction, & unit testing Software Engineering Semester Project Chih-Hong Jeng & Farn Wang fall 2006
2 Deadline and what you need to prepare Deadline: 2006/11/21 (by Prof. Wang ’ s schedule) It seems to be difficult to finish it on time You have to ask for sure. What you need to prepare for submission: A demonstration of your current progress, i.e., your program must run in some way … A written report specifying your functionalities, a brief manual. Your code, your test data.
3 Implementation Problems relating to Rational Rose ® : Lack of integration with current software developing IDE. You have to write your code outside Rose ®. When you use Java as your developing platform, the code generation and reverse engineering requires IBM VisualAge VisualAge is totally out of date, but you can still find it. Not included in IBM Academic Initiative, use trial version. Now everyone uses Eclipse, Netbeans, Jbuilder or … Rational Software Architect support the integration of Java into Eclipse.
4 So … If you are using Java platform, I encourage you to switch your platform into IBM XDE developer for Java. It has Eclipse bundled in it. Although it remains an older product. But I ’ m trying to import Rose project into XDE What about the one using C++? Yes, it supports the translation from model to standard C++ and Visual C But I think that you will not use those old tools.
5 Good Gospel! You may use what ever IDE you like to implement your code. Use UML as your guideline toward your implementation. As you submit your code, you may have to spend some time describing the relation between your code and your diagram. But make sure that you perform unit testing. In Java, this is achieved by using JUnit.
6 JUnit JUnit is a testing framework. By applying the tools it offered, you may reduce the probability writing “ wrong ” test programs. It ’ s a tool enabling you to perform unit testing with ease. You don ’ t have to use “ system.out.println( “ ” ); ” It has been bundled in various IDEs. Java NetBeans, Borland JBuilder, Eclipse … In JUnit you have to "Keep the bar green to keep the code clean."
7 Using JUnit to check correctness: Sample GCD calculator
8 A glance of Netbeans IDE Appearance of window Main part of calculating GCD
9 GCD.java public class GCD { /** Creates a new instance of GCD */ public GCD() { } public int use_gcd(int num1, int num2) { int r = 0; while(num2 != 0) { r = num1 % num2; num1 = num2; num2 = r; } return num1; } }
10 We want to generate JUnit test case template of GCD.java Tools Create JUnit tests
11 The content of GCDTest.java (All these contents are generated automatically) Modify it based on your understanding of the GCD module! // Assertion: Check if the expected result and generated result are the same!
12 A simple modification of test cases Note that all these fixtures can be managed. Visit for more!
13 Execute the Unit Test When the word is green, it means that it passes; When the word is red, it means that it fails.
14 End