Java Code Examples for org.testng.ITestContext#getOutputDirectory()

The following examples show how to use org.testng.ITestContext#getOutputDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JUnitXMLReporter.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked after the test class is instantiated and before any configuration method is called.
 */
public void onStart(ITestContext context) {
    System.out.println("Changing System.out...");
    while (System.out instanceof SysOutPrintStream) {
        System.setOut(((SysOutPrintStream) System.out).getOriginalSysOut());
    }
    while (System.err instanceof SysOutPrintStream) {
        System.setErr(((SysOutPrintStream) System.err).getOriginalSysOut());
    }
    old_stdout = System.out;
    old_stderr = System.err;
    unsolicitedOut = new ByteArrayOutputStream();
    unsolicitedErr = new ByteArrayOutputStream();
    suffix = System.getProperty(SUFFIX);
    if (suffix != null)
        suffix = suffix.trim();
    output_dir = context.getOutputDirectory(); // + File.separator + context.getName() + suffix + ".xml";

    System.setOut(new SysOutPrintStream(new JUnitXMLReporterOutputStream(this, 1), old_stdout));

    System.setErr(new SysOutPrintStream(new JUnitXMLReporterOutputStream(this, 2), old_stderr));
}
 
Example 2
Source File: JUnitXMLReporter.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked after the test class is instantiated and before any configuration method is called.
 */
public void onStart(ITestContext context) {
    System.out.println("Changing System.out...");
    while (System.out instanceof SysOutPrintStream) {
        System.setOut(((SysOutPrintStream) System.out).getOriginalSysOut());
    }
    while (System.err instanceof SysOutPrintStream) {
        System.setErr(((SysOutPrintStream) System.err).getOriginalSysOut());
    }
    old_stdout = System.out;
    old_stderr = System.err;
    unsolicitedOut = new ByteArrayOutputStream();
    unsolicitedErr = new ByteArrayOutputStream();
    suffix = System.getProperty(SUFFIX);
    if (suffix != null)
        suffix = suffix.trim();
    output_dir = context.getOutputDirectory(); // + File.separator + context.getName() + suffix + ".xml";

    System.setOut(new SysOutPrintStream(new JUnitXMLReporterOutputStream(this, 1), old_stdout));

    System.setErr(new SysOutPrintStream(new JUnitXMLReporterOutputStream(this, 2), old_stderr));
}
 
Example 3
Source File: JUnitXMLReporter.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
/** Invoked at the start of the test, before any of the classes in the test are run */
public void onStart(ITestContext context) {
    output_dir=context.getOutputDirectory();
    // Uncomment to delete dir created by previous run of this testsuite
    File dir=new File(output_dir);
    if(dir.exists())
        deleteContents(dir);

    try {
        System.setOut(new MyOutput(1));
        System.setErr(new MyOutput(2));
    }
    catch(FileNotFoundException e) {
    }
}
 
Example 4
Source File: SeleneseTestNgHelper.java    From selenium with Apache License 2.0 5 votes vote down vote up
@BeforeSuite
@Parameters({"selenium.host", "selenium.port"})
public void attachScreenshotListener(@Optional("localhost") String host,
    @Optional("4444") String port, ITestContext context) {
  if (!"localhost".equals(host)) {
    return;
  }
  Selenium screenshotTaker = new DefaultSelenium(host, Integer.parseInt(port),
      "", "");
  TestRunner tr = (TestRunner) context;
  File outputDirectory = new File(context.getOutputDirectory());
  tr.addListener((IResultListener) new ScreenshotListener(outputDirectory,
      screenshotTaker));
}
 
Example 5
Source File: ScreenshotListener.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public void onStart(ITestContext context) {
  outputDirectory = new File(context.getOutputDirectory());
}