slides

advertisement
Design, construction, & unit testing
Software Engineering
Semester Project
Chih-Hong Jeng & Farn Wang
fall 2006
1
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.
2
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.
3
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++ 6.0

But I think that you will not use those old tools.
4
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.
5
JUnit

JUnit is a testing framework. By applying the
tools it offered, you may reduce the
probability writing “wrong” test programs.



It has been bundled in various IDEs.


It’s a tool enabling you to perform unit testing
with ease.
You don’t have to use “system.out.println(“”);”
Java NetBeans, Borland JBuilder, Eclipse…
In JUnit you have to "Keep the bar green to
keep the code clean."
6
Using JUnit to check correctness:
Sample GCD calculator
7
A glance of Netbeans IDE
Main part of calculating GCD
Appearance of window
8
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;
}
}
9
Tools  Create JUnit tests
We want to generate JUnit test
case template of GCD.java
10
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!
11
A simple modification of test cases
Note that all these fixtures can be managed.
Visit www.Junit.org for more!
12
Execute the Unit Test
When the word is green, it means that it passes;
When the word is red, it means that it fails.
13
End
14
Download