下面列出了怎么用org.testng.ITest的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
} else {
// something else, don't care about the order
return 0;
}
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
} else {
// something else, don't care about the order
return 0;
}
}
});
return methods;
}
@Override
public List<IMethodInstance> intercept(final List<IMethodInstance> methods, final ITestContext context) {
Collections.sort(methods, new Comparator<IMethodInstance>() {
@Override
public int compare(final IMethodInstance mi1, final IMethodInstance mi2) {
// get test instances to order the tests.
final Object o1 = mi1.getInstance();
final Object o2 = mi2.getInstance();
if (o1 instanceof ITest && o2 instanceof ITest) {
return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName());
}
// something else, don't care about the order
return 0;
}
});
return methods;
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
*/
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
*/
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
/**
* Creates a test factory for the set of .js source tests.
*
* @return a Object[] of test objects.
* @throws Exception upon failure
*/
@SuppressWarnings("static-method")
@Factory
public Object[] suite() throws Exception {
Locale.setDefault(new Locale(""));
final List<ITest> tests = new ArrayList<>();
final Set<String> orphans = new TreeSet<>();
final TestFactory<ITest> testFactory = new TestFactory<ITest>() {
@Override
public ITest createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
return new ScriptRunnable(framework, testFile, engineOptions, testOptions, scriptArguments);
}
@Override
public void log(final String msg) {
org.testng.Reporter.log(msg, true);
}
};
TestFinder.findAllTests(tests, orphans, testFactory);
if (System.getProperty(TEST_JS_INCLUDES) == null) {
tests.add(new OrphanTestFinder(orphans));
}
return tests.toArray();
}
@BeforeMethod(alwaysRun = true)
public void findMethodName(Method method) {
if (this instanceof ITest) {
name = ((ITest) this).getTestName();
} else {
name = method.getName();
}
}