diff --git a/docs/media/naturalFRUIT-logo-short.svg b/docs/media/naturalFRUIT-logo-short.svg
index d97d1fb..1808d52 100644
--- a/docs/media/naturalFRUIT-logo-short.svg
+++ b/docs/media/naturalFRUIT-logo-short.svg
@@ -18,7 +18,7 @@
viewBox="0 0 169.38593 89.927794"
sodipodi:docname="naturalFRUIT-logo-short.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
- inkscape:export-filename="/home/cibin/WorkInProgress/naturalFRUIT/media/naturalFRUIT-logo.png"
+ inkscape:export-filename="/home/cibin/WorkInProgress/naturalFRUIT/media/naturalFRUIT-logo-short.png"
inkscape:export-xdpi="201.19501"
inkscape:export-ydpi="201.19501">
Contents
-
© 2020
+
diff --git a/docs/module/naturalfruit.html b/docs/module/naturalfruit.html
index 889777b..c53ba5b 100644
--- a/docs/module/naturalfruit.html
+++ b/docs/module/naturalfruit.html
@@ -7840,7 +7840,7 @@
Arguments
-
© 2020
+
diff --git a/docs/page/AssertMethods/index.html b/docs/page/AssertMethods/index.html
index 2b82c33..d091978 100644
--- a/docs/page/AssertMethods/index.html
+++ b/docs/page/AssertMethods/index.html
@@ -199,12 +199,12 @@
3. assert_identical
- Tutorial 0
+ Tutorial 1
- Tutorial 1
+ Tutorial 2
@@ -223,7 +223,7 @@ 3. assert_identical
-
© 2020
+
diff --git a/docs/page/DeprecatedMethods/index.html b/docs/page/DeprecatedMethods/index.html
index 95d20d1..1ed3eb6 100644
--- a/docs/page/DeprecatedMethods/index.html
+++ b/docs/page/DeprecatedMethods/index.html
@@ -185,12 +185,12 @@
Deprecated methods
- Tutorial 0
+ Tutorial 1
- Tutorial 1
+ Tutorial 2
@@ -209,7 +209,7 @@ Deprecated methods
-
© 2020
+
diff --git a/docs/page/MajorChanges/index.html b/docs/page/MajorChanges/index.html
index 6b3f8c9..f888f06 100644
--- a/docs/page/MajorChanges/index.html
+++ b/docs/page/MajorChanges/index.html
@@ -169,12 +169,12 @@
Major changes
- Tutorial 0
+ Tutorial 1
- Tutorial 1
+ Tutorial 2
@@ -193,7 +193,7 @@ Major changes
-
© 2020
+
diff --git a/docs/page/Tutorials/index.html b/docs/page/Tutorials/index.html
index 7d9f2af..8522f95 100644
--- a/docs/page/Tutorials/index.html
+++ b/docs/page/Tutorials/index.html
@@ -116,10 +116,10 @@
Tutorials
Subsections:
-
Tutorial 0
-
Tutorial 1
+
Tutorial 2
+
-->
@@ -207,12 +207,12 @@
Contents:
- Tutorial 0
+ Tutorial 1
- Tutorial 1
+ Tutorial 2
@@ -231,7 +231,7 @@ Contents:
-
© 2020
+
diff --git a/docs/page/Tutorials/tutorial0/index.html b/docs/page/Tutorials/tutorial0/index.html
deleted file mode 100644
index bfb001f..0000000
--- a/docs/page/Tutorials/tutorial0/index.html
+++ /dev/null
@@ -1,358 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
Tutorial 0 – naturalFRUIT
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Testing the matmul
intrinsic function
-
In order to understand the basic workflow of unit testing, let's try verifying the matmul
intrinsic function that performs matrix multiplication in Fortran.
-Let's start with integer multiplication for 2 x 2 matrices.
-We shall take two example matrices and use the assert_equal statement to compare the expected matrix result with the one matmul
outputs.
-Let's also deliberately add a wrong case that results in a failed assert statement.
-
program matmul_test
- use naturalfruit
-
- integer , dimension ( 2 , 2 ) :: a , b
- integer , dimension ( 2 , 2 ) :: expectedMat , obtainedMat
-
- a ( 1 , :) = ( / 1 , 2 / )
- a ( 2 , :) = ( / 3 , 4 / )
-
- b ( 1 , :) = ( / 5 , 6 / )
- b ( 2 , :) = ( / 7 , 8 / )
-
- expectedMat ( 1 , :) = ( / 19 , 22 / )
- expectedMat ( 2 , :) = ( / 43 , 50 / )
-
- obtainedMat = matmul ( a , b )
-
- call assert_equal ( expectedMat , obtainedMat ) ! <--- Assert statement
- call assert_equal ( expectedMat , obtainedMat + 1 ) ! <--- Assert statement
-
-end program matmul_test
-
-
-
-
-Ensure the module naturalfruit.f90
is available for use and available for linking. Our example program may then be compiled and executed using:
-
$ gfortran -c naturalfruit.f90
-$ gfortran matmul_test.f90 naturalfruit.o
-$ ./a.out
-
-
-
-
Executing this program will print a .F
to the screen. The .
indicates a successful assert while the F
a failed assert. This is a concise indication common to other testing frameworks too.
-For a clearer outline of the results, we leverage nauralFRUIT's testsuite_summary method. We shall also supply assert_equal an optional message
argument to print out a message in case of a failed assert. This would allow us to better identify the failed assert.
-Making these changes in the program,
-
program matmul_test
- use naturalfruit
-
- integer , dimension ( 2 , 2 ) :: a , b
- integer , dimension ( 2 , 2 ) :: expectedMat , obtainedMat
-
- a ( 1 , :) = ( / 1 , 2 / )
- a ( 2 , :) = ( / 3 , 4 / )
-
- b ( 1 , :) = ( / 5 , 6 / )
- b ( 2 , :) = ( / 7 , 8 / )
-
- expectedMat ( 1 , :) = ( / 19 , 22 / )
- expectedMat ( 2 , :) = ( / 43 , 50 / )
-
- obtainedMat = matmul ( a , b )
-
- call assert_equal ( expectedMat , obtainedMat , 'Fail 1' ) ! <--- Assert statement
- call assert_equal ( expectedMat , obtainedMat + 1 , 'Fail 2' ) ! <--- Assert statement
- call testsuite_summary () ! <--- Print results summary
-
-end program matmul_test
-
-
-
-
and executing it will provide:
-
.F
-
- Start of FRUIT summary:
-
- Some tests failed!
-
- -- Failed assertion messages:
- [ _not_set_] : Expected [ 19 ] , Got [ 20 ] ; User message: [ 2d array has difference, Fail 2 ]
- -- end of failed assertion messages.
-
- Total asserts : 2
- Successful : 1
- Failed : 1
-Successful rate: 50 .00%
-
- Successful asserts / total asserts : [ 1 / 2 ]
- Successful cases / total cases : [ 0 / 1 ]
- -- end of FRUIT summary
-
-
-
-
Although naturalFRUIT is currently working with set defaults, it requires to be properly initialized to prevent unexpected beahviour. For this, we shall utilize the testsuite_initialize
and the testsuite_finalize
statements. We will also provide an optional integer argument exit_code
to testsuite_finalize
to obtain an exit code for our test program. This will indicate whether program as a whole was successfully executed and be helpful when integrating with other frameworks including those with continuous integration testing capabilities.
-
program matmul_test
- use naturalfruit
-
- integer , dimension ( 2 , 2 ) :: a , b
- integer , dimension ( 2 , 2 ) :: expectedMat , obtainedMat
- integer :: exit_code ! <--- Declare exit_code
-
- call testsuite_initialize () ! <--- Initialize testsuite
-
- a ( 1 , :) = ( / 1 , 2 / )
- a ( 2 , :) = ( / 3 , 4 / )
-
- b ( 1 , :) = ( / 5 , 6 / )
- b ( 2 , :) = ( / 7 , 8 / )
-
- expectedMat ( 1 , :) = ( / 19 , 22 / )
- expectedMat ( 2 , :) = ( / 43 , 50 / )
-
- obtainedMat = matmul ( a , b )
-
- call assert_equal ( expectedMat , obtainedMat , 'Fail 1' ) ! <--- Assert statement
- call assert_equal ( expectedMat , obtainedMat + 1 , 'Fail 2' ) ! <--- Assert statement
- call testsuite_summary () ! <--- Print results summary
-
- call testsuite_finalize ( exit_code ) ! <--- Finalize testsuite
- call exit ( exit_code ) ! <--- Exit using exit_code
-
-end program matmul_test
-
-
-
-
We have now realized the bare minimum to perform unit testing with naturalFRUIT.
-This program may be easily extended to testing other data types like real
and real*8
too.
-However, for maintaining a testsuite with a large number of complex testcases, we cannot rely only on a simple testrunner program like the above. A better organization of things is essential. Continue to the next tutorial to find how this may be achieved.
-
Next Tutorial
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Documentation generated by
- FORD
-
-
-
-
naturalFRUIT was developed by Cibin Joseph
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/page/Tutorials/tutorial1/index.html b/docs/page/Tutorials/tutorial1/index.html
index 81ed216..d1c0da3 100644
--- a/docs/page/Tutorials/tutorial1/index.html
+++ b/docs/page/Tutorials/tutorial1/index.html
@@ -132,8 +132,86 @@
Tutorial 1
Using a module to organize testcases
-
Note Documentation under construction
-
+
For complex programs, placing your test cases in a seperate module allows better management and utilization of data between test cases.
+Let's take the following simple calculator module that simulates the integer add and multiply operators and perform unit tests on the defined functions.
+
module calculator
+ implicit none
+contains
+
+ subroutine add ( a , b , output )
+ !! A subroutine to add two integers
+ integer , intent ( in ) :: a , b
+ integer , intent ( out ) :: output
+ output = a + b
+ end subroutine add
+
+ subroutine multiply ( a , b , output )
+ !! A subroutine to multiply two integers
+ integer , intent ( in ) :: a , b
+ integer , intent ( out ) :: output
+ output = a * b
+ end subroutine multiply
+
+end module calculator
+
+
+
+
We create the following test module that performs unit tests on each of the functions defined in the source module. Let's call it calculator_test.f90
.
+
module calculator_test
+ use naturalfruit
+ implicit none
+contains
+
+ subroutine add_test ()
+ use calculator , only : add
+ integer :: result
+
+ call testcase_initialize ( 'add_test' )
+ call add ( 2 , 2 , result ) ! <--- Call function to be tested
+ call assert_equals ( 4 , result ) ! <--- A sample assert that returns true
+ call assert_equals ( 4 , result + 1 ) ! <--- A sample assert that returns false
+ call testcase_finalize ()
+
+ end subroutine add_test
+
+ subroutine multiply_test ()
+ use calculator , only : multiply
+ integer :: result
+
+ call testcase_initialize ( 'multiply_test' )
+ call multiply ( 3 , 4 , result ) ! <--- Call function to be tested
+ call assert_equals ( 12 , result , 'Multiply failed' ) ! <--- A sample assert that returns true
+ call assert_equals ( 12 , result + 1 , 'Multiply failed' ) ! <--- A sample assert that returns false
+ call testcase_finalize ()
+
+ end subroutine multiply_test
+
+end module calculator_test
+
+
+
+
We've now created two subroutines that test the add
and multiply
functions from the module calculator
. Note that each test subroutine starts with a testcase_initialize
and ends with a testcase_finalize
subroutine call. These are required for bookkeeping and proper initialization of internal variables.
+
To run these test cases, we create a test runner program. The test runner decides which test cases to run, in what order and acts as the frontend to interacting with the test cases helping provide result summaries of all test cases executed. Let us name our test runner calculator_testrunner.f90
.
+
program calculator_testrunner
+ use naturalfruit
+ use calculator_test
+ integer :: exit_code
+
+ call testsuite_initialize ()
+
+ call add_test ()
+ call multiply_test ()
+
+ call testsuite_summary ()
+ call testsuite_finalize ( exit_code )
+ call exit ( exit_code )
+
+end program calculator_testrunner
+
+
+
+
Notice how the initialize -test -finalize workflow is used here just like in the test module.
+The subroutine names in the testrunner program start with the word 'testsuite' similar to how those in the test cases start with 'testcase'. Multiple such testsuites may be containd within a single testrunner program. This form of testing will be demonstrated in the next tutorial.
Prev Tutorial
@@ -171,13 +249,13 @@ Using a module to organize testcases
-
- Tutorial 0
+
+ Tutorial 1
-
- Tutorial 1
+
+ Tutorial 2
@@ -196,7 +274,7 @@ Using a module to organize testcases
-
© 2020
+
diff --git a/docs/page/Tutorials/tutorial2/index.html b/docs/page/Tutorials/tutorial2/index.html
new file mode 100644
index 0000000..eb978bc
--- /dev/null
+++ b/docs/page/Tutorials/tutorial2/index.html
@@ -0,0 +1,244 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
Tutorial 2 – naturalFRUIT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Documentation generated by
+ FORD
+
+
+
+
naturalFRUIT was developed by Cibin Joseph
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/page/index.html b/docs/page/index.html
index e6e9ee4..42bb814 100644
--- a/docs/page/index.html
+++ b/docs/page/index.html
@@ -205,12 +205,12 @@
naturalFRUIT
- Tutorial 0
+ Tutorial 1
- Tutorial 1
+ Tutorial 2
@@ -229,7 +229,7 @@ naturalFRUIT
-
© 2020
+
diff --git a/docs/proc/add_success.html b/docs/proc/add_success.html
index 96c0f51..f4489ec 100644
--- a/docs/proc/add_success.html
+++ b/docs/proc/add_success.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/assert_false.html b/docs/proc/assert_false.html
index b625e80..f3cb5c4 100644
--- a/docs/proc/assert_false.html
+++ b/docs/proc/assert_false.html
@@ -332,7 +332,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/assert_identical.html b/docs/proc/assert_identical.html
index fb12593..4fe2a19 100644
--- a/docs/proc/assert_identical.html
+++ b/docs/proc/assert_identical.html
@@ -347,7 +347,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/assert_not_identical.html b/docs/proc/assert_not_identical.html
index 2759478..be43bea 100644
--- a/docs/proc/assert_not_identical.html
+++ b/docs/proc/assert_not_identical.html
@@ -347,7 +347,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/assert_true.html b/docs/proc/assert_true.html
index 81cfbd9..6182feb 100644
--- a/docs/proc/assert_true.html
+++ b/docs/proc/assert_true.html
@@ -332,7 +332,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/case_failed_xml.html b/docs/proc/case_failed_xml.html
index 9be5682..f911d1c 100644
--- a/docs/proc/case_failed_xml.html
+++ b/docs/proc/case_failed_xml.html
@@ -317,7 +317,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/case_passed_xml.html b/docs/proc/case_passed_xml.html
index 9d8e3e3..f6adb74 100644
--- a/docs/proc/case_passed_xml.html
+++ b/docs/proc/case_passed_xml.html
@@ -317,7 +317,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/end_override_stdout.html b/docs/proc/end_override_stdout.html
index fed0354..6b0e7ee 100644
--- a/docs/proc/end_override_stdout.html
+++ b/docs/proc/end_override_stdout.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/end_override_xml_work.html b/docs/proc/end_override_xml_work.html
index ca6e69e..9642a22 100644
--- a/docs/proc/end_override_xml_work.html
+++ b/docs/proc/end_override_xml_work.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/failed_assert_action.html b/docs/proc/failed_assert_action.html
index 14c9568..c81acf0 100644
--- a/docs/proc/failed_assert_action.html
+++ b/docs/proc/failed_assert_action.html
@@ -347,7 +347,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/fruit_hide_dots.html b/docs/proc/fruit_hide_dots.html
index fed1c53..ad6527d 100644
--- a/docs/proc/fruit_hide_dots.html
+++ b/docs/proc/fruit_hide_dots.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/fruit_if_case_failed.html b/docs/proc/fruit_if_case_failed.html
index e085a88..42db4ee 100644
--- a/docs/proc/fruit_if_case_failed.html
+++ b/docs/proc/fruit_if_case_failed.html
@@ -285,7 +285,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/fruit_show_dots.html b/docs/proc/fruit_show_dots.html
index 54baaf0..52673d2 100644
--- a/docs/proc/fruit_show_dots.html
+++ b/docs/proc/fruit_show_dots.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_assert_and_case_count.html b/docs/proc/get_assert_and_case_count.html
index f60f4da..4ae883c 100644
--- a/docs/proc/get_assert_and_case_count.html
+++ b/docs/proc/get_assert_and_case_count.html
@@ -347,7 +347,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_case_name.html b/docs/proc/get_case_name.html
index aeaacfa..d03037d 100644
--- a/docs/proc/get_case_name.html
+++ b/docs/proc/get_case_name.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_failed_count.html b/docs/proc/get_failed_count.html
index ac08938..b24f3b5 100644
--- a/docs/proc/get_failed_count.html
+++ b/docs/proc/get_failed_count.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_last_message.html b/docs/proc/get_last_message.html
index 3f13cec..e0bd9b8 100644
--- a/docs/proc/get_last_message.html
+++ b/docs/proc/get_last_message.html
@@ -285,7 +285,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_message_array.html b/docs/proc/get_message_array.html
index 0475a2e..9f8ddea 100644
--- a/docs/proc/get_message_array.html
+++ b/docs/proc/get_message_array.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_message_index.html b/docs/proc/get_message_index.html
index 244b92d..62ee0a7 100644
--- a/docs/proc/get_message_index.html
+++ b/docs/proc/get_message_index.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_messages.html b/docs/proc/get_messages.html
index c96a739..a34283b 100644
--- a/docs/proc/get_messages.html
+++ b/docs/proc/get_messages.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_prefix.html b/docs/proc/get_prefix.html
index 41d57a5..fa9a22f 100644
--- a/docs/proc/get_prefix.html
+++ b/docs/proc/get_prefix.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_total_count.html b/docs/proc/get_total_count.html
index 7e410d4..06bb786 100644
--- a/docs/proc/get_total_count.html
+++ b/docs/proc/get_total_count.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/get_xml_filename_work.html b/docs/proc/get_xml_filename_work.html
index aa75b0c..f58a8bd 100644
--- a/docs/proc/get_xml_filename_work.html
+++ b/docs/proc/get_xml_filename_work.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/is_all_successful.html b/docs/proc/is_all_successful.html
index b4bfc24..e4866b6 100644
--- a/docs/proc/is_all_successful.html
+++ b/docs/proc/is_all_successful.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/is_case_passed.html b/docs/proc/is_case_passed.html
index 0c1f3da..a46d8cc 100644
--- a/docs/proc/is_case_passed.html
+++ b/docs/proc/is_case_passed.html
@@ -285,7 +285,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/is_last_passed.html b/docs/proc/is_last_passed.html
index c1e5d79..e70d993 100644
--- a/docs/proc/is_last_passed.html
+++ b/docs/proc/is_last_passed.html
@@ -285,7 +285,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/override_stdout.html b/docs/proc/override_stdout.html
index f015799..baf79fa 100644
--- a/docs/proc/override_stdout.html
+++ b/docs/proc/override_stdout.html
@@ -317,7 +317,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/override_xml_work.html b/docs/proc/override_xml_work.html
index c99fa86..e5d6977 100644
--- a/docs/proc/override_xml_work.html
+++ b/docs/proc/override_xml_work.html
@@ -317,7 +317,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/restore_test_suite.html b/docs/proc/restore_test_suite.html
index 283b470..4f22a87 100644
--- a/docs/proc/restore_test_suite.html
+++ b/docs/proc/restore_test_suite.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/set_case_name.html b/docs/proc/set_case_name.html
index 792d96c..4737eb8 100644
--- a/docs/proc/set_case_name.html
+++ b/docs/proc/set_case_name.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/set_prefix.html b/docs/proc/set_prefix.html
index 4feb82f..9ac4fb9 100644
--- a/docs/proc/set_prefix.html
+++ b/docs/proc/set_prefix.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/set_xml_filename_work.html b/docs/proc/set_xml_filename_work.html
index 21ba2cb..adea168 100644
--- a/docs/proc/set_xml_filename_work.html
+++ b/docs/proc/set_xml_filename_work.html
@@ -302,7 +302,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/stash_test_suite.html b/docs/proc/stash_test_suite.html
index feca625..09cf8a7 100644
--- a/docs/proc/stash_test_suite.html
+++ b/docs/proc/stash_test_suite.html
@@ -276,7 +276,7 @@
Contents
-
© 2020
+
diff --git a/docs/proc/testcase_finalize.html b/docs/proc/testcase_finalize.html
index fa94459..abe549e 100644
--- a/docs/proc/testcase_finalize.html
+++ b/docs/proc/testcase_finalize.html
@@ -304,7 +304,7 @@
Contents