From 947603b5d7f05053a93a3cfe257fa7ab11304a90 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Thu, 8 May 2014 21:16:31 +0200 Subject: Implemented black-box test cases * the directories below "./test" contain test cases ** "transformation.xsl" and the expected result as "reference.xml" ** tests are performed by "check.sh" *** returns diff on error * this system enables simple verification of external function results ** way simpler than C++ unit tests would be in this scenario * expanded cmake instructions to automatically execute the test cases * old example transformation was removed --- CMakeLists.txt | 7 +++ dummy/in.xml | 2 - dummy/test.txt | 7 --- dummy/transform.xsl | 83 ---------------------------------- test/check.sh | 24 ++++++++++ test/common/test.txt | 7 +++ test/read_directory/reference.xml | 9 ++++ test/read_directory/transformation.xsl | 26 +++++++++++ test/read_file/reference.xml | 11 +++++ test/read_file/transformation.xsl | 24 ++++++++++ test/read_xml_file/reference.xml | 9 ++++ test/read_xml_file/transformation.xsl | 26 +++++++++++ 12 files changed, 143 insertions(+), 92 deletions(-) delete mode 100644 dummy/in.xml delete mode 100644 dummy/test.txt delete mode 100644 dummy/transform.xsl create mode 100755 test/check.sh create mode 100644 test/common/test.txt create mode 100644 test/read_directory/reference.xml create mode 100644 test/read_directory/transformation.xsl create mode 100644 test/read_file/reference.xml create mode 100644 test/read_file/transformation.xsl create mode 100644 test/read_xml_file/reference.xml create mode 100644 test/read_xml_file/transformation.xsl diff --git a/CMakeLists.txt b/CMakeLists.txt index b6229ca..2171d0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,10 @@ target_link_libraries( test ${Libraries} ) + +add_custom_command( + TARGET + test + POST_BUILD COMMAND + cd ../test && ./check.sh +) diff --git a/dummy/in.xml b/dummy/in.xml deleted file mode 100644 index 6abcacd..0000000 --- a/dummy/in.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/dummy/test.txt b/dummy/test.txt deleted file mode 100644 index 046a6ef..0000000 --- a/dummy/test.txt +++ /dev/null @@ -1,7 +0,0 @@ - - - Hello 1 - Hello 2 - Hello 3 - Hello 4 - diff --git a/dummy/transform.xsl b/dummy/transform.xsl deleted file mode 100644 index 5e172b6..0000000 --- a/dummy/transform.xsl +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - -
- Parameter "test" contains value "" -
- -
- - - - Could not read text file. - - - - - -
- -
- - - - Could not read XML file. - - -
    - -
  • -
    -
-
-
-
- -
- - - - Could not read directory. - - -
    - -
  • -
    -
-
    - -
  • -
    -
-
-
-
- - -
- -
- - diff --git a/test/check.sh b/test/check.sh new file mode 100755 index 0000000..fd537d7 --- /dev/null +++ b/test/check.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +for testcase in *; +do + if [ -d $testcase ] && [ "$testcase" != "common" ] + then + echo $testcase + + cd $testcase + rm -f actual.xml + + ./../../build/test --transformation transformation.xsl --target actual.xml + diff -u reference.xml actual.xml + + if [ $? = 0 ] + then + echo "passed." + else + echo "failed." + fi + + cd .. + fi +done diff --git a/test/common/test.txt b/test/common/test.txt new file mode 100644 index 0000000..046a6ef --- /dev/null +++ b/test/common/test.txt @@ -0,0 +1,7 @@ + + + Hello 1 + Hello 2 + Hello 3 + Hello 4 + diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml new file mode 100644 index 0000000..7e83460 --- /dev/null +++ b/test/read_directory/reference.xml @@ -0,0 +1,9 @@ + + + +read_directory +read_xml_file +common +read_file + + diff --git a/test/read_directory/transformation.xsl b/test/read_directory/transformation.xsl new file mode 100644 index 0000000..d3c21f1 --- /dev/null +++ b/test/read_directory/transformation.xsl @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/test/read_file/reference.xml b/test/read_file/reference.xml new file mode 100644 index 0000000..7cbcc95 --- /dev/null +++ b/test/read_file/reference.xml @@ -0,0 +1,11 @@ + + +<?xml version="1.0"?> +<tester> + <eintrag>Hello 1</eintrag> + <eintrag>Hello 2</eintrag> + <eintrag>Hello 3</eintrag> + <eintrag>Hello 4</eintrag> +</tester> + + diff --git a/test/read_file/transformation.xsl b/test/read_file/transformation.xsl new file mode 100644 index 0000000..96b8976 --- /dev/null +++ b/test/read_file/transformation.xsl @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/test/read_xml_file/reference.xml b/test/read_xml_file/reference.xml new file mode 100644 index 0000000..d82dc9c --- /dev/null +++ b/test/read_xml_file/reference.xml @@ -0,0 +1,9 @@ + + + +Hello 1 +Hello 2 +Hello 3 +Hello 4 + + diff --git a/test/read_xml_file/transformation.xsl b/test/read_xml_file/transformation.xsl new file mode 100644 index 0000000..ba6fed1 --- /dev/null +++ b/test/read_xml_file/transformation.xsl @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + -- cgit v1.2.3