4 echo "Usage of the script: ./master_test_script.sh destination_folder_for_test_reports tests_folder_location"
6 ##########################################################
7 # This script is executed from /scripts directory #
8 # in situare project folder #
9 ##########################################################
11 echo "This is the master script for building and executing all automatic unit test."
12 echo "As a final step, it creates summary report from all tests executed."
13 ##########################################################
14 #Environment settings #
15 ##########################################################
16 #Store all directory names to a list
17 #Modify these paths to point to correct path
20 echo "Tests situate at: $location"
23 echo "Directory to store test report: $1"
25 if [ ! -e $1/tests_summary.txt ]; then
26 touch $1/tests_summary.txt
27 echo "##########################################" >> tests_summary.txt
28 echo "# Summary of unit tests executed #" >> tests_summary.txt
29 echo "# Date: `date` #" >> tests_summary.txt
30 echo "# User: `whoami` #" >> tests_summary.txt
31 echo "##########################################" >> tests_summary.txt
34 FILE=$1/tests_summary.txt
39 for component in "${MODULES[@]}"
41 echo "Found test directory: $component"
44 ##########################################################
45 #First part: Execution of all tests #
46 ##########################################################
47 for component in "${MODULES[@]}" #Loop through components
49 cd $location/$component
50 CASES=(`ls`) #List all test cases under component directory
51 for unittest in "${CASES[@]}"
53 cd $location/$component/$unittest
54 echo "Building tests for $component/$unittest"
57 echo "Running tests for $component/$unittest"
58 ./$unittest -o testreport_$component.txt
59 echo "Cleaning $unittest"
66 #########################################################
67 # Second part: Extraction of results #
68 #########################################################
69 echo "Summarizing test results....."
70 for component in "${MODULES[@]}" #Loop through components
72 cd $location/$component
73 CASES=(`ls`) #List all test cases uner component directory
74 for unittests in "${CASES[@]}"
76 cd $location/$component/$unittests
77 echo "############# $component/$unittests ################" >> $FILE
78 grep Totals *.txt >> $FILE