ソフトウェアテスト
[10] リファクタリング演演
習
Software Testing
[10] Refactoring Exercise & Seminar
あまん ひろひさ ひろひさ
阿萬 裕久 裕久( AMAN
Hirohisa )
(C) 2007-2022 Hirohisa AMAN
1
Exercise purpose
Refactoring program to experience an
d learn the importance of writing in an
easy-to-understand manner
Main contents
Improve unorganized indentation, variabl
e names, and function names in confusin
g prog ram
Improve long unorg anized program prog ram
Reg ression testing along with refactoring
(C) 2007-2022 Hirohisa AMAN
2
Exercise content
Exercise 1
Refactor programs that are completely unor
ganized for indentation, variable names, an
d function names
However, do regression testing as well
Exercise 2
Refactor a given program
Do regression testing as well
(C) 2007-2022 Hirohisa AMAN
3
Exercise 1 (1/2)
[Target program] sample1001.c
This program is supposed to sort inte
gers, but due to poor writing,
it is incomprehensible content
First, look at the specification spec1001.
pdf Create test cases and run tests Wri
te the contents in test-report1001.xls
x
(Think more than 5)
(C) 2007-2022 Hirohisa AMAN
4
Exercise 1 (2/2)
Note the following points in sample100
1.c Perf orm refactoring :
Ind programentation
Variable name
Function name
Add comments
if necessary
Then, test with the test cases you prepare test with the test cases you prepare
d program (record programed program in test-report1001.xlsx) and program
make sure that they work correctly even
after refactoring (This is called program reg ression
testing .)
(C) 2007-2022 Hirohisa AMAN
5
Submission of Exercise 1
If you do pair programming
Submit to Teams
with two people, both of you
should submit the same thing.
sample1001.c and
test-report1001.xlsx
[10] Exercise-1 (Refactoring)
Submission deadline: May 16,
13:00 (Vietnam time)
(C) 2007-2022 Hirohisa AMAN
6
Exercise 2 (1/2)
[Target program] sample1002.c
This program is Binary and program d programecimal co
nversion, test with the test cases you prepare but it is bad program writing .
First, look at the specification spec1002.
pdf Create test cases and run tests Wri
te the contents in test-report1002.xls
x
(Think more than 5)
(C) 2007-2022 Hirohisa AMAN
7
Exercise 2 (2/2)
Note the following points in sample100
2.c Perf orm refactoring :
Split the contents of main function into functi
ons
Add comments
Make variable names meaning ful
if necessary
Turn hard programcod programing into macros
Then, test with the test cases you prepare test with the test cases you prepare
d program (record programed program in test-report1002.xlsx) and program
make sure that they work correctly even
after refactoring
(C) 2007-2022 Hirohisa AMAN
8
Submission of Exercise 2
If you do pair programming
Submit to Teams
with two people, both of you
should submit the same thing.
sample1002.c and
test-report1002.xlsx
[10] Exercise-2 (Refactoring)
Submission deadline: May 22,
13:00 (Vietnam time)
(C) 2007-2022 Hirohisa AMAN
9
Survey
In this exercise, you can do it alone,
or you can do pair programming with
2 people.
I want to know which one you chose,
so please answer the survey first
[10] Survey (you must answer first)
(C) 2007-2022 Hirohisa AMAN
10