-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·61 lines (49 loc) · 2.21 KB
/
test.sh
File metadata and controls
executable file
·61 lines (49 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# ==================================================
# --> Set working dirctory as the location of the script
# ==================================================
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
cd $SCRIPT_DIR
# ==================================================
# --> Cleanup bin files (if any)
# ==================================================
binFolderPath="./bin"
binTestFolderPath="./bin_test"
[ -d $binFolderPath ] && rm -r $binFolderPath
[ -d $binTestFolderPath ] && rm -r $binTestFolderPath
# ==================================================
# --> Find Java source files (*.java) and JAR files (*.jar)
# ==================================================
javaFiles=""
javaTestFiles=""
jarFiles=""
while IFS= read -r file; do
javaFiles="$javaFiles $file"
done < <(find ./src -name "*.java" -type f)
while IFS= read -r file; do
javaTestFiles="$javaTestFiles $file"
done < <(find ./test -name "*.java" -type f)
while IFS= read -r file; do
jarFiles="$jarFiles:$file"
done < <(find ./lib -name "*.jar" -type f)
# Build the classpath for any JAR files found in the source directory and its subdirectories
classpath=${jarFiles#;}
# ==================================================
# --> Compiles java files
# ==================================================
# Compile the Java source files
javac -d $binFolderPath -cp "$classpath" $javaFiles
# Compile the Java source files
javac -d $binTestFolderPath -cp "$classpath:$binFolderPath" $javaTestFiles
# ==================================================
# --> Run tests
# ==================================================
java -cp "$classpath:$binTestFolderPath:$binFolderPath" org.junit.runner.JUnitCore test.TestUserDao
java -cp "$classpath:$binTestFolderPath:$binFolderPath" org.junit.runner.JUnitCore test.TestPostDao
java -cp "$classpath:$binTestFolderPath:$binFolderPath" org.junit.runner.JUnitCore test.TestParser
java -cp "$classpath:$binTestFolderPath:$binFolderPath" org.junit.runner.JUnitCore test.TestTransformer
# ==================================================
# --> Cleanup bin files
# ==================================================
[ -d $binFolderPath ] && rm -r $binFolderPath
[ -d $binTestFolderPath ] && rm -r $binTestFolderPath