Generate test cases documentation from robot test suites.
Resolves: openbmc/openbmc-test-automation#547
Change-Id: I5b08b57b3955f0abd5cf4b0bc2201a8651297392
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/README.md b/README.md
index aa9de2e..8ec7c89 100755
--- a/README.md
+++ b/README.md
@@ -175,3 +175,17 @@
Example for getting openbmc-test-automation issues
python ./tools/github_issues_to_csv <github user> openbmc/openbmc-test-automation
```
+
+
+Command to generate Robot test cases test documentations
+
+```shell
+./tools/generate_test_document <Robot test cases directory path> <test case document file path>
+
+Example for generating tests cases documentation for tests directory
+./tools/generate_test_document tests testsdirectoryTCdocs.html
+
+Example for generating tests cases documentation (tests,gui,extended TCs)
+# Note: Invoke the tool with out argument
+./tools/generate_test_document
+```
diff --git a/tools/generate_test_document b/tools/generate_test_document
new file mode 100755
index 0000000..b1315e4
--- /dev/null
+++ b/tools/generate_test_document
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+# This program will generate test documenation from the robot test cases.
+
+# Description of argument(s):
+# test_dir_path Test directory where robot test cases are available.
+# test_case_doc_file_path The test case document file path to be stored.
+
+
+###############################################################################
+function get_parms {
+
+ # Get program parms.
+
+ test_dir_path="${1}" ; shift
+ test_case_doc_file_path="${1}" ; shift
+
+ return 0
+
+}
+###############################################################################
+
+
+###############################################################################
+function validate_parms {
+
+ # Validate program parameters.
+
+ num_parms="${1}" ; shift
+
+ (( ${num_parms} == 0 )) && return 0
+
+ if [ -z "${test_dir_path}" ] ; then
+ echo "**ERROR** You must provide test directory as the first positional" \
+ "parameter." >&2
+ return 1
+ fi
+
+ if [ -z "${test_case_doc_file_path}" ] ; then
+ echo "**ERROR** You must provide file path as the second positional" \
+ "parameter." >&2
+ return 1
+ fi
+
+ return 0
+
+}
+###############################################################################
+
+
+###############################################################################
+function generate_all_test_document {
+
+ # Generate all test case documents
+
+ local ret_code=0
+ python -m robot.testdoc tests testsdirectoryTCdocs.html || ret_code=1
+ python -m robot.testdoc extended extendeddirectoryTCdocs.html || ret_code=1
+ python -m robot.testdoc gui guidirectoryTCdocs.html || ret_code=1
+ python -m robot.testdoc systest systestdirectoryTCdocs.html || ret_code=1
+
+ return ${ret_code}
+}
+###############################################################################
+
+
+###############################################################################
+function main_function {
+
+ get_parms "$@" || return 1
+
+ validate_parms $# || return 1
+
+ if (( ${num_parms} == 0 )) ; then
+ generate_all_test_document || return 1
+ return 0
+ fi
+
+ echo ${test_dir_path} ${test_case_doc_file_path}
+ python -m robot.testdoc ${test_dir_path} ${test_case_doc_file_path}\
+ || return 1
+
+ return 0
+
+}
+###############################################################################
+
+
+###############################################################################
+# Main
+
+ main_function "${@}"
+ rc="${?}"
+ exit "${rc}"
+
+###############################################################################