testng.xml上的组交集

时间:2016-07-28 09:08:28

标签: java maven selenium testng beanshell

您好我正在尝试在testng.xml中创建一个组交集但是当我运行maven命令时,我有一个NullPointerException。

这是套件:

<test name="test">
    <method-selectors>
        <method-selector>
            <script language="beanshell"><![CDATA[
            runTest = false;
            groupIn = System.getProperty("includeGroups");
            groupNotIn = System.getProperty("excludeGroups");

            if ((groupIn == null) || (groupIn == "")) {
                runTest = false;
            } else {
                StringTokenizer groupsTagList = new StringTokenizer(groupIn, ",");
                runTest = true;

                while (groupsTagList.hasMoreTokens()) {
                  if (!(groups.containsKey(groupsTagList.nextToken())))
                    runTest = false;
                }

                if (runTest && (groupNotIn != null) && (groupNotIn != "")) {
                    StringTokenizer groupsNotInList = new StringTokenizer(groupNotIn, ",");

                    while (groupsNotInList.hasMoreTokens()) {
                       if ((groups.containsKey(groupsNotInList.nextToken())))
                         runTest = false;
                    }
                 }
            }
            return runTest;
            ]]>
            </script>
        </method-selector>
    </method-selectors>
    <packages>
        <package name="tests.*"></package>
    </packages>
</test>

输出:

ERROR in execution: java.lang.NullPointerException
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.402 sec - in TestSuite

命令:

 mvn -DSELENIUM_IS_LOCAL=true -Dbrowser=firefox -Dhub=http://127.0.0.1:4444/wd/hub clean test -DincludeGroups=groupA,groupB

0 个答案:

没有答案