diff options
Diffstat (limited to 'eclass/java-utils-2.eclass')
-rw-r--r-- | eclass/java-utils-2.eclass | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 29f13e031f48..a33962f114de 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -1861,6 +1861,44 @@ ejunit4() { ejunit_ "junit-4" "${@}" } +# @FUNCTION: etestng +# @USAGE: etestng_ [-cp $classpath] <test classes> +# @INTERNAL +# @DESCRIPTION: +# Testng wrapper function. Makes it easier to run the tests. +# Launches the tests using org.testng.TestNG. +# +# @CODE +# $1 - -cp or -classpath +# $2 - the classpath passed to it +# $@ - test classes for testng to run. +# @CODE +etestng() { + debug-print-function ${FUNCNAME} $* + + local runner=org.testng.TestNG + local cp=$(java-pkg_getjars --with-dependencies testng) + local tests + + if [[ ${1} = -cp || ${1} = -classpath ]]; then + cp="${cp}:${2}" + shift 2 + else + cp="${cp}:." + fi + + for test in ${@}; do + tests+="${test}," + done + + debug-print "java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\""\ + "-Djava.awt.headless=true ${runner}"\ + "-usedefaultlisteners false -testclass ${tests}" + java -cp "${cp}" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true\ + ${runner} -usedefaultlisteners false -testclass ${tests}\ + || die "Running TestNG failed." +} + # @FUNCTION: java-utils-2_src_prepare # @DESCRIPTION: # src_prepare Searches for bundled jars |