File tree Expand file tree Collapse file tree 4 files changed +44
-3
lines changed
codecademy/intermediate_course Expand file tree Collapse file tree 4 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 1+ package codecademy .intermediate_course ;
2+
3+ import org .junit .runner .JUnitCore ;
4+ import org .junit .runner .Result ;
5+ import org .junit .runner .notification .Failure ;
6+
7+ public class FactorialTestRunner {
8+ public static void main (String [] args ) {
9+ Result result = JUnitCore .runClasses (FactorialTestSuite .class );
10+
11+ for (Failure failure : result .getFailures ()) {
12+ System .out .println (failure .toString ());
13+ }
14+
15+ System .out .println (result .wasSuccessful ());
16+
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ package codecademy .intermediate_course ;
2+
3+ import org .junit .runner .RunWith ;
4+ import org .junit .runners .Suite ;
5+ import org .junit .runners .Suite .SuiteClasses ;
6+
7+ @ RunWith (Suite .class )
8+ @ Suite .SuiteClasses ({
9+ // List of test classes to bundle togethe
10+ TestFactorial .class
11+ })
12+
13+ // No content needed - just a dummy prop for the test runner
14+ public class FactorialTestSuite {
15+
16+ }
Original file line number Diff line number Diff line change 11package codecademy .intermediate_course ;
22
33import org .junit .Test ;
4+ // NOTE: 'static' imports allow pulling static methods from classes
45import static org .junit .Assert .*;
56
67public class TestFactorial {
Original file line number Diff line number Diff line change @@ -7,10 +7,16 @@ if [ $# -ne 1 ]; then
77fi
88
99# Set up environment
10- JAVA_TESTSUITE =" $1 "
10+ JAVA_TESTCASE =" $1 "
1111JAVA_CODE_DIR=" $( pwd) /codecademy/intermediate_course"
1212export JUNIT4_CLASSPATH=" /usr/share/java/junit-4.13.2.jar:/usr/share/java/hamcrest-core.jar"
1313
1414# Run test cases
15- javac -cp ./:${JUNIT4_CLASSPATH} ${JAVA_CODE_DIR} /${JAVA_TESTSUITE} .java ${JAVA_CODE_DIR} /Factorial.java
16- java -cp ./:${JUNIT4_CLASSPATH} org.junit.runner.JUnitCore codecademy.intermediate_course.${JAVA_TESTSUITE}
15+ pushd $JAVA_CODE_DIR
16+ javac -cp ./:${JUNIT4_CLASSPATH} \
17+ ${JAVA_TESTCASE} .java \
18+ Test${JAVA_TESTCASE} .java \
19+ ${JAVA_TESTCASE} TestSuite.java \
20+ ${JAVA_TESTCASE} TestRunner.java
21+ popd
22+ java -cp ./:${JUNIT4_CLASSPATH} org.junit.runner.JUnitCore codecademy.intermediate_course.${JAVA_TESTCASE} TestSuite
You can’t perform that action at this time.
0 commit comments