Top Description Fields Constructors Methods
org.testng.xml.internal

public final Class TestNamesMatcher

extends Object
Class Inheritance
Imports
java.util.List, org.testng.TestNGException, org.testng.collections.Lists, org.testng.log4testng.Logger, org.testng.util.Strings, org.testng.xml.XmlSuite, .XmlTest

The class to work with "-testnames", "-ignoreMissedTestNames", and VM argument "-Dtestng.ignore.missed.testnames". If both "-ignoreMissedTestNames" and VM argument "-Dtestng.ignore.missed.testnames" are set, then either of them has "true" value will enable the feature to ingore partially missed test names and run those existing test names.

Field Summary

Modifier and TypeField and Description
private final List<XmlSuite>
private final boolean
private static final Logger
private final List<String>
private final List<XmlTest>
private final List<String>

Constructor Summary

AccessConstructor and Description
public
TestNamesMatcher(XmlSuite xmlSuite, List<String> testNames)

public
TestNamesMatcher(XmlSuite xmlSuite, List<String> testNames, boolean ignoreMissedTestNames)

Method Summary

Modifier and TypeMethod and Description
private void
private static XmlSuite
cleanClone(XmlSuite xmlSuite, List<XmlTest> tests)

private void
cloneIfContainsTestsWithNamesMatchingAny(XmlSuite
The XmlSuite to work with.
xmlSuite
,
List<String>
The list of testnames to iterate through
testNames
)

Recursive search the given testNames from the current XmlSuite and its child suites.

private XmlSuite
public List<XmlTest>
public List<String>
public List<XmlSuite>
public boolean

Returns:

boolean if ignoreMissedTestNames disabled, then return true if no missed test names in suite, otherwise throw TestNGException; if ignoreMissedTestNames enabled, then return true if any test names exist in suite, otehrwise (all given test names are missed) throw TestNGException.
validateMissMatchedTestNames
()

Do validation for testNames and notify users if any testNames are missed in suite.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cloneSuitesback to summary
private final List<XmlSuite> cloneSuites
ignoreMissedTestNamesback to summary
private final boolean ignoreMissedTestNames
LOGGERback to summary
private static final Logger LOGGER
matchedTestNamesback to summary
private final List<String> matchedTestNames
matchedTestsback to summary
private final List<XmlTest> matchedTests
testNamesback to summary
private final List<String> testNames

Constructor Detail

TestNamesMatcherback to summary
public TestNamesMatcher(XmlSuite xmlSuite, List<String> testNames)
TestNamesMatcherback to summary
public TestNamesMatcher(XmlSuite xmlSuite, List<String> testNames, boolean ignoreMissedTestNames)

Method Detail

addIfNotNullback to summary
private void addIfNotNull(XmlSuite xmlSuite)
cleanCloneback to summary
private static XmlSuite cleanClone(XmlSuite xmlSuite, List<XmlTest> tests)
cloneIfContainsTestsWithNamesMatchingAnyback to summary
private void cloneIfContainsTestsWithNamesMatchingAny(XmlSuite xmlSuite, List<String> testNames)

Recursive search the given testNames from the current XmlSuite and its child suites.

Parameters
xmlSuite:XmlSuite

The XmlSuite to work with.

testNames:List<String>

The list of testnames to iterate through

cloneIfSuiteContainTestsWithNamesMatchingAnyback to summary
private XmlSuite cloneIfSuiteContainTestsWithNamesMatchingAny(XmlSuite suite)
getMatchedTestsback to summary
public List<XmlTest> getMatchedTests()
getMissedTestNamesback to summary
public List<String> getMissedTestNames()
getSuitesMatchingTestNamesback to summary
public List<XmlSuite> getSuitesMatchingTestNames()
validateMissMatchedTestNamesback to summary
public boolean validateMissMatchedTestNames()

Do validation for testNames and notify users if any testNames are missed in suite. This method is also used to decide how to run test suite when test names are given. In legacy logic, if test names are given and exist in suite, then run them; if any of them do not exist in suite, then throw exception and exit. After ignoreMissedTestNames is introduced, if ignoreMissedTestNames is enabled, then any of the given test names exist in suite will be run, and print warning message to tell those test names do not exist in suite.

Returns:boolean

boolean if ignoreMissedTestNames disabled, then return true if no missed test names in suite, otherwise throw TestNGException; if ignoreMissedTestNames enabled, then return true if any test names exist in suite, otehrwise (all given test names are missed) throw TestNGException.