Skip to content

Commit

Permalink
Refactor and fix test-triangle examples
Browse files Browse the repository at this point in the history
Add:
 * Documentation for the test scripts

Fix:
 * Scripts so that the tests would pass

Refactor:
 * Format to better separate the tasks
 * Output of results to be more apparent
  • Loading branch information
kevinjalbert committed Jan 30, 2012
1 parent 125fbf5 commit e2c2671
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 16 deletions.
35 changes: 27 additions & 8 deletions test-triangle-junit4.sh
@@ -1,39 +1,58 @@
#! /bin/bash
VERSION=`grep "<version>" pom.xml | head -1 | sed -E 's/.*0/0/' | sed -E 's/<.*//'`
DIST=javalanche-$VERSION

# Set up test example
cd ${DIST}/examples/triangleJunit4
JAVALANCHE_ARGS="-Dprefix=triangle -Dcp=target/classes -Djavalanche=../../ -Dtests=triangle.tests.Triangle1Test:triangle.tests.Triangle2Test:triangle.tests.Triangle3Test"
ant test
cp ../../javalanche.xml .

# Variables representing the two test's properties and their output locations
OUT1=out-mutationTest-1.txt
OUT2=out-mutationTest-2.txt
cp ../../javalanche.xml .
ant -f javalanche.xml $JAVALANCHE_ARGS mutationTest | tee ${OUT1}
sed -iBACK 's/<project name="Javalanche">/& \
<property name="prefix" value="triangle"\/> \
<property name="tests" value="triangle.tests.TriangleTestSuite"\/> \
<property name="javalanche" value="..\/..\/"\/> \
<property name="cp" value="target\/classes"\/> /' javalanche.xml
<property name="cp" value="target\/classes"\/> /' javalanche.xml
JAVALANCHE_ARGS="-Dprefix=triangle -Dcp=target/classes -Djavalanche=../../ -Dtests=triangle.tests.Triangle1Test:triangle.tests.Triangle2Test:triangle.tests.Triangle3Test"

# Test 1: using javalanche.xml properties with JUnit TestSuite
ant -f javalanche.xml $JAVALANCHE_ARGS mutationTest | tee ${OUT1}

# Test 2: using CLI arguments with JUnit Tests (composes testsuite)
ant -f javalanche.xml mutationTest | tee ${OUT2}

# Clean up test
ant clean
rm javalanche.xml

SAME="Same output for both runs"
# Variables required for the comparison of the output
SAME="Successful: Same output for both runs"
GREP1_1="$(grep "Mutation score:" ${OUT1})"
GREP1_2="$(grep "Mutation score:" ${OUT2})"
GREP2_1="$(grep "Covered mutations" ${OUT1})"
GREP2_2="$(grep "Covered mutations" ${OUT2})"

# Output the test results
echo "-------------------------------------"
echo "Testing Mutation Score"
if [ "$GREP1_1" == "$GREP1_2" ]
then
echo ${SAME}
else
echo Error: Mutation score not equal. ${GREP1_2} - ${GREP1_1}
fi

GREP2_1="$(grep "Covered mutations" ${OUT1})"
GREP2_2="$(grep "Covered mutations" ${OUT2})"
echo ""
echo "Testing Covered Mutations"
if [ "$GREP2_1" == "$GREP2_2" ]
then
echo ${SAME}
else
echo Error: Covered mutations not equal. ${GREP2_2} - ${GREP2_1}
fi


# Clean up output files
rm ${OUT1}
rm ${OUT2}
42 changes: 34 additions & 8 deletions test-triangle.sh
@@ -1,18 +1,26 @@
#! /bin/bash
VERSION=`grep "<version>" pom.xml | head -1 | sed -E 's/.*0/0/' | sed -E 's/<.*//'`
DIST=javalanche-$VERSION

# Set up test example
cd ${DIST}/examples/triangle
ant test
cp ../../javalanche.xml .

# Variables representing the two test's properties and their output locations
OUT1=out-mutationTest.txt
OUT2=out-analyzeResults.txt
cp ../../javalanche.xml .
JAVALANCHE_PROPERTIES_1="-Dprefix=triangle -Dcp=target/classes/:./lib/junit.jar -Djavalanche=../../ -Dtests=triangle.tests.TriangleTestSuite "
JAVALANCHE_PROPERTIES_2="-Dprefix=triangle -Dcp=target/classes/:./lib/junit.jar -Djavalanche=../../ -Dtests=triangle.tests.Triangle1Test:triangle.tests.Triangle2Test:triangle.tests.Triangle3Test"

# Test 1: using mutationTest task with the JUnit TestSuite
ant -f javalanche.xml ${JAVALANCHE_PROPERTIES_1} mutationTest | tee ${OUT1}

# Test 2: using individual tasks with multiple JUnit Tests (composes testsuite)
ant -f javalanche.xml -Djavalanche=../../ startHsql
ant -f javalanche.xml -Djavalanche=../../ schemaexport
JAVALANCHE_PROPERTIES_1="-Dprefix=triangle -Dcp=target/classes/:./lib/junit.jar -Djavalanche=../../ -Dtests=triangle.tests.TriangleTestSuite "
#ant -f javalanche.xml ${JAVALANCHE_PROPERTIES_1} mutationTest | tee ${OUT1}
ant -f javalanche.xml -Djavalanche=../../ startHsql
ant -f javalanche.xml -Djavalanche=../../ schemaexport
JAVALANCHE_PROPERTIES_2="-Dprefix=triangle -Dcp=target/classes/:./lib/junit.jar -Djavalanche=../../ -Dtests=triangle.tests.Triangle1Test" #:triangle.tests.Triangle2Test:triangle.tests.Triangle3Test
ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 testTask1
ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 testTask2
ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 testTask3
Expand All @@ -23,26 +31,44 @@ ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 runMutations -Dmutation.file=./mu
ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 analyzeResults | tee ${OUT2}
ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 cleanJavalanche
ant -f javalanche.xml $JAVALANCHE_PROPERTIES_2 schemaexport

# Variables required for the comparison of the output
SAME="Successful: Same output for both runs"
GREP1_1="$(grep "Mutation score:" ${OUT1})"
GREP1_2="$(grep "Mutation score:" ${OUT2})"
GREP2_1="$(grep "Covered mutations" ${OUT1})"
GREP2_2="$(grep "Covered mutations" ${OUT2})"

# Clean up test
ant clean
rm javalanche.xml

SAME="Same output for both runs"
# Variables required for the comparison of the output
SAME="Successful: Same output for both runs"
GREP1_1="$(grep "Mutation score:" ${OUT1})"
GREP1_2="$(grep "Mutation score:" ${OUT2})"
GREP2_1="$(grep "Covered mutations" ${OUT1})"
GREP2_2="$(grep "Covered mutations" ${OUT2})"

# Output the test results
echo "-------------------------------------"
echo "Testing Mutation Score"
if [ "$GREP1_1" == "$GREP1_2" ]
then
echo ${SAME}
else
echo Error: Mutation score not equal. ${GREP1_2} - ${GREP1_1}
fi

GREP2_1="$(grep "Covered mutations" ${OUT1})"
GREP2_2="$(grep "Covered mutations" ${OUT2})"
echo ""
echo "Testing Covered Mutations"
if [ "$GREP2_1" == "$GREP2_2" ]
then
echo ${SAME}
else
echo Error: Covered mutations not equal. ${GREP2_2} - ${GREP2_1}
fi


# Clean up output files
rm ${OUT1}
rm ${OUT2}

0 comments on commit e2c2671

Please sign in to comment.