Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
96175e8
week6: parameterized2.0
lihungte96 Mar 25, 2019
ef80520
Readme in repo
lihungte96 Mar 26, 2019
1ddb599
fix: typo in parameterized2.
lihungte96 Mar 28, 2019
1b9238d
fix Polymorphism in parameterized2.0
lihungte96 Mar 28, 2019
1da1ba0
week7: jacoco
lihungte96 Apr 1, 2019
3d5bcf7
week7: edit Makefile
lihungte96 Apr 1, 2019
0968249
Highlight URL in showCov, edit readme for week 8, add Dockfile
lihungte96 Apr 10, 2019
21d74b4
jacoco: add make kill, to retrieve
lihungte96 Apr 10, 2019
069f7b2
Mockito stub
lihungte96 Apr 15, 2019
72e9f42
mock
lihungte96 Apr 15, 2019
09d1b1f
update week 9 readme
lihungte96 Apr 15, 2019
f0061a8
week 9: TcpClient.java pass Socket into TcpClientParser
lihungte96 Apr 16, 2019
4571ba2
week 9: enviroment setup
lihungte96 Apr 16, 2019
018a226
remove openjdk-11 on machine
lihungte96 Apr 18, 2019
a017155
split testcase file
lihungte96 Apr 18, 2019
86dca98
write message when try to connect with remote server
lihungte96 Apr 18, 2019
f3156ae
week10 mock2
lihungte96 Apr 22, 2019
dacb296
Week 10
lihungte96 Apr 23, 2019
e3fb45d
week 10: mock2 add lib
lihungte96 Apr 23, 2019
1edc0e8
week 10: stubLW
lihungte96 Apr 24, 2019
4a02d44
stubLW ready
lihungte96 Apr 25, 2019
3f936b1
week11
lihungte96 Apr 30, 2019
1061c72
travis
lihungte96 May 7, 2019
cbde2a6
selenium
lihungte96 May 21, 2019
5dbfdc5
week14
lihungte96 May 21, 2019
88e7c16
week 16
lihungte96 Jun 4, 2019
5ea1eb1
week 16
lihungte96 Jun 4, 2019
6c2720b
Update teiba_member_number.py
lihungte96 Jun 4, 2019
44db8ce
Update teiba_slogan.py
lihungte96 Jun 4, 2019
19f92e1
Update teiba_member_number.py
lihungte96 Jun 4, 2019
f2283ba
Update teiba_slogan.py
lihungte96 Jun 4, 2019
16f68c7
Update teiba_slogan.py
lihungte96 Jun 4, 2019
f2cac27
Update teiba_member_number.py
lihungte96 Jun 4, 2019
c8deccd
Update teiba_slogan.py
lihungte96 Jun 4, 2019
288f2eb
Update teiba_member_number.py
lihungte96 Jun 4, 2019
51de482
afl
Jun 11, 2019
f396e1f
remove old file
Jun 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Software Testing class 2019

## [JUnit](junit)
Week 3: 2019/03/07
Week 4: 2019/03/14
* Week 3: 2019/03/07
* Week 4: 2019/03/14
* Week 5: 2019/03/21
* Week 6: 2019/03/28
* Week 7: 2019/04/04
* Week 8: 2019/04/11
* Week 9: 2019/04/16
* Week 10: 2019/04/23
* Week 11: 2019/04/30

## [travis](https://github.com/lihungte96/Software-testing-2019-travis)
* Week 12: 2019/05/07
* Week 13: 2019/05/14

## [Selenium](selenium)
* Week 14: 2019/05/21
* Week 16: 2019/06/04

## [afl](afl)
* Week 17: 2019/06/11
3 changes: 3 additions & 0 deletions afl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fuzz_output
sample1
sample2
13 changes: 13 additions & 0 deletions afl/sample1_positive/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
all: sample1

sample1:
$(CXX) sample1.cpp -o sample1

fuzz: sample1
afl-fuzz -i testcase/ -o fuzz_output/ ./sample1

fuzz_non_instrument: sample1
afl-fuzz -n -i testcase/ -o fuzz_output/ ./sample1

clean:
rm sample1
12 changes: 12 additions & 0 deletions afl/sample1_positive/sample1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
using namespace std;
int main(){
int a =0;
cin >> a;
if (a >= 0)
cout << "positive number!" << endl;
else
cout << "negative number!" << endl;
return 0;
}

1 change: 1 addition & 0 deletions afl/sample1_positive/testcase/a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
14 changes: 14 additions & 0 deletions afl/sample2_ctf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all: sample2

sample2: sample2.cpp
afl-g++ sample2.cpp -o sample2

asan: sample2.cpp
afl-g++ -fsanitize=address sample2.cpp -o sample2

fuzz: sample2
afl-fuzz -m 30000000 -i testcase/ -o fuzz_output/ ./sample2

clean:
rm sample2

20 changes: 20 additions & 0 deletions afl/sample2_ctf/sample2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
int main()
{
int a[20];
int index = 0;

cout << "Index: ";
// chose an index to write
cin >> index;

// check index position
if (index >= 20)
return -1;

cout << "Value: ";
// write data to index
cin >> a[index];
return 0;
}
1 change: 1 addition & 0 deletions afl/sample2_ctf/testcase/input1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10 50
10 changes: 10 additions & 0 deletions afl/sample3_crash_hang/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
all: sample3

sample3: sample3.cpp
afl-g++ -fsanitize=address sample3.cpp -o sample3

fuzz: sample3
afl-fuzz -m 300000000 -i testcase/ -o fuzz_output/ ./sample3

clean:
rm sample3
Binary file added afl/sample3_crash_hang/sample3
Binary file not shown.
23 changes: 23 additions & 0 deletions afl/sample3_crash_hang/sample3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <stdexcept>
using namespace std;
#define length 20
int main()
{
int index = 0;
int array[length];
cout << "Index: ";
cin >> index;

// hang
if (index >= length)
while (true)
;

// crash
if (index == -6666)
throw std::invalid_argument("You did it");

//array[index] = 0;
return 0;
}
1 change: 1 addition & 0 deletions afl/sample3_crash_hang/testcase/input1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+1
1 change: 1 addition & 0 deletions afl/sample3_crash_hang/testcase/input2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1
1 change: 1 addition & 0 deletions afl/sample3_crash_hang/testcase/input3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 1 2 3 4 5 6 7 8 9
5 changes: 5 additions & 0 deletions junit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:18.04
MAINTAINER robert

RUN apt-get update -y &&
apt-get install git openjdk-8-jdk-headless junit4 make libmockito-java -y
31 changes: 25 additions & 6 deletions junit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,33 @@ $ make

## syllabus
### week3
#### [onlyTest](onlyTest): Only JUint test
#### [testCode](testCode): Simple assert
#### [OnlyTest](onlyTest): Only JUint test
#### [TestCode](testCode): Simple assert

### week4
#### [beforeAfter](beforeAfter): Show execution path of before and after annotation
#### [BeforeAfter](beforeAfter): Show execution path of before and after annotation
#### [Stack](Stack): Use stack example show why use before and after annotation

### week5
#### [parameterized](parameterized): Use JUnit @parameterized annotation to generate multiple tese case
#### [testException1](testException1): Use stack example show how to check exception with test
#### [testException2](testException2): Use stack example show how to check exception with test rule
#### [Parameterized](parameterized): Use JUnit @parameterized annotation to generate multiple tese case

### week6
#### [Parameterized2.0](parameterized2.0): Use JUnit @parameterized annotation to generate multiple tese case(homework version)
#### [TestException1](testException1): Use stack example show how to check exception with test
#### [TestException2](testException2): Use stack example show how to check exception with test rule

### week7
#### [Jacoco](jacoco): Use jacoco to run & cal & show coverage information

### week8
#### [Jacoco Labwork](jacocoLW): Labwork for jacoco, need add testcase and achieve 100% coverage

### week9
#### [Stub](stub): Stub example, and use Mockito to stub

### week10
#### [Mock](mock): Mock example, and use Mockito to mock
#### [Mock2](mock2): Mock Mazu example, and use Mockito to mock

### week11
#### [StubLW](stubLW): Labwork for Stub, complete testcase & achieve 100% coverage in multiplicationWithArray method
30 changes: 25 additions & 5 deletions junit/jacoco/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
all: compile compileTest

Simple: compileTest runCov calCov showCov
Positive: compileTestPositive runCovPositive calCovPositive showCov
Negative: compileTestNegative runCovNegative calCovNegative showCov

compile:
mkdir -p bin
javac src/Distant.java -d bin
Expand All @@ -9,11 +13,15 @@ compileTest:
javac -classpath /usr/share/java/junit4.jar src/Distant.java \
testcase/TestDistant.java testcase/TestRunner.java -d bin

compileTestPositive:
mkdir -p bin
javac -classpath /usr/share/java/junit4.jar src/Distant.java \
testcase/TestDistantPositive.java testcase/TestRunnerPositive.java -d bin
testcase/Positive/TestDistantPositive.java testcase/Positive/TestRunnerPositive.java -d bin

compileTestNegative:
mkdir -p bin
javac -classpath /usr/share/java/junit4.jar src/Distant.java \
testcase/TestDistantNegative.java testcase/TestRunnerNegative.java -d bin
testcase/Negative/TestDistantNegative.java testcase/Negative/TestRunnerNegative.java -d bin

test:
cd bin ; java -classpath .:/usr/share/java/junit4.jar TestRunner
Expand All @@ -29,10 +37,22 @@ runCovNegative:

calCov:
cd bin ; java -jar ../lib/jacococli.jar report jacoco.exec --classfiles ../bin \
--sourcefiles ../src --sourcefiles ../testcase --html report
--sourcefiles ../src --sourcefiles ../testcase --html reportDir

calCovPositive:
cd bin ; java -jar ../lib/jacococli.jar report jacoco.exec --classfiles ../bin \
--sourcefiles ../src --sourcefiles ../testcase/Positive --html reportDir

calCovNegative:
cd bin ; java -jar ../lib/jacococli.jar report jacoco.exec --classfiles ../bin \
--sourcefiles ../src --sourcefiles ../testcase/Negative --html reportDir

showCov:
cd bin/report ; python3 -m http.server 8000
RED="\033[0;31m" ; NC='\033[0m' ; printf "$${RED}http://" ; curl -s https://api.ipify.org/ ; printf ":8000/$${NC}\n"
cd bin/reportDir ; python3 -m http.server 8000

kill:
killall python3

clean:
rm bin/*.class bin/*.exec
rm -r bin/*.class bin/*.exec bin/reportDir bin/Positive bin/Negative || true
12 changes: 12 additions & 0 deletions junit/jacoco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Makefile
make [all] - Compile JAVA class

make compileTest - Compile Junit testing class

make runCov - Execute & record code coverage

make calCov - Calculate coverage & report to a HTML file

make showCov - Use python HTTP server to show HTML

make clean - removes all files generated by make
58 changes: 58 additions & 0 deletions junit/jacocoLW/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
all: compile compileTest

Simple: compileTest runCov calCov showCov
Positive: compileTestPositive runCovPositive calCovPositive showCov
Negative: compileTestNegative runCovNegative calCovNegative showCov

compile:
mkdir -p bin
javac src/Distant.java src/UnhandledCaseException.java -d bin

compileTest:
mkdir -p bin
javac -classpath /usr/share/java/junit4.jar src/Distant.java src/UnhandledCaseException.java \
testcase/TestDistant.java testcase/TestRunner.java -d bin

compileTestPositive:
mkdir -p bin
javac -classpath /usr/share/java/junit4.jar src/Distant.java src/UnhandledCaseException.java \
testcase/Positive/TestDistantPositive.java testcase/Positive/TestRunnerPositive.java -d bin

compileTestNegative:
mkdir -p bin
javac -classpath /usr/share/java/junit4.jar src/Distant.java src/UnhandledCaseException.java \
testcase/Negative/TestDistantNegative.java testcase/Negative/TestRunnerNegative.java -d bin

test:
cd bin ; java -classpath .:/usr/share/java/junit4.jar TestRunner

runCov:
cd bin ; java -javaagent:../lib/jacocoagent.jar -cp /usr/share/java/junit4.jar:. TestRunner

runCovPositive:
cd bin ; java -javaagent:../lib/jacocoagent.jar -cp /usr/share/java/junit4.jar:. TestRunnerPositive

runCovNegative:
cd bin ; java -javaagent:../lib/jacocoagent.jar -cp /usr/share/java/junit4.jar:. TestRunnerNegative

calCov:
cd bin ; java -jar ../lib/jacococli.jar report jacoco.exec --classfiles ../bin \
--sourcefiles ../src --sourcefiles ../testcase --html reportDir

calCovPositive:
cd bin ; java -jar ../lib/jacococli.jar report jacoco.exec --classfiles ../bin \
--sourcefiles ../src --sourcefiles ../testcase/Positive --html reportDir

calCovNegative:
cd bin ; java -jar ../lib/jacococli.jar report jacoco.exec --classfiles ../bin \
--sourcefiles ../src --sourcefiles ../testcase/Negative --html reportDir

showCov:
RED="\033[0;31m" ; NC='\033[0m' ; printf "$${RED}http://" ; curl -s https://api.ipify.org/ ; printf ":8000/$${NC}\n"
cd bin/reportDir ; python3 -m http.server 8000

kill:
killall python3

clean:
rm -r bin/*.class bin/*.exec bin/reportDir bin/Positive bin/Negative || true
11 changes: 11 additions & 0 deletions junit/jacocoLW/lib/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Manifest-Version: 1.0
Implementation-Title: JaCoCo Java Agent
Automatic-Module-Name: org.jacoco.agent.rt
Premain-Class: org.jacoco.agent.rt.internal_1f1cc91.PreMain
Implementation-Version: 0.8.3
Archiver-Version: Plexus Archiver
Built-By: godin
Created-By: Apache Maven
Build-Jdk: 1.8.0_152
Implementation-Vendor: Mountainminds GmbH & Co. KG

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Wed Jan 23 02:22:02 CET 2019
version=0.8.3
groupId=org.jacoco
artifactId=org.jacoco.agent.rt
Loading