Skip to content

Instantly share code, notes, and snippets.

@abangser
Last active October 9, 2021 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abangser/59d3a72de592aaf0696353b55f7bec4f to your computer and use it in GitHub Desktop.
Save abangser/59d3a72de592aaf0696353b55f7bec4f to your computer and use it in GitHub Desktop.
This gist is helpful during Chapter 8 of the TAU course
#!/usr/bin/bash
###################################################################################################
# This is extracting the values for each test suite description. #
# It uses awk to print the value between two quotes. #
# The columns printed is based on the following example string: #
# <testng-results ignored="0" total="23" passed="22" failed="1" skipped="0"> #
###################################################################################################
TEST_RESULTS_LOCATION="${1:-/home/runner/work/selenium-webdriver-java-course/selenium-webdriver-java-course/webdriver_java/target/surefire-reports}"
TEST_RESULTS_STRING=$(cat "${TEST_RESULTS_LOCATION}/testng-results.xml" | grep "<testng-results")
echo "IGNORED_TESTS=$(echo ${TEST_RESULTS_STRING} | awk -F'"' '{ print $2 }')"
echo "TOTAL_TESTS=$(echo ${TEST_RESULTS_STRING} | awk -F'"' '{ print $4 }')"
echo "PASSED_TESTS=$(echo ${TEST_RESULTS_STRING} | awk -F'"' '{ print $6 }')"
echo "FAILED_TESTS=$(echo ${TEST_RESULTS_STRING} | awk -F'"' '{ print $8 }')"
echo "SKIPPED_TESTS=$(echo ${TEST_RESULTS_STRING} | awk -F'"' '{ print $10 }')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment