Title: Design, construction,
1Design, construction, unit testing
- Software Engineering
- Semester Project
- Chih-Hong Jeng Farn Wang
- fall 2006
2Deadline and what you need to prepare
- Deadline 2006/11/21 (by Prof. Wangs 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.
3Implementation
- 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.
4So
- 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 Im 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 6.0 - But I think that you will not use those old
tools.
5Good 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.
6JUnit
- JUnit is a testing framework. By applying the
tools it offered, you may reduce the probability
writing wrong test programs. - Its a tool enabling you to perform unit testing
with ease. - You dont 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."
7Using JUnit to check correctnessSample GCD
calculator
8A glance of Netbeans IDE
Main part of calculating GCD
Appearance of window
9GCD.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
-
-
10Tools ? Create JUnit tests
We want to generate JUnit test case template of
GCD.java
11The 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!
12A simple modification of test cases
Note that all these fixtures can be managed.
Visit www.Junit.org for more!
13Execute the Unit Test
When the word is green, it means that it
passes When the word is red, it means that it
fails.
14End