Share this page

# Report code samples (Java SDK)

In this topic:

## Customize the Report settings

This example shows how to customize the OpenText Functional Testing for Developers run report settings.

    @Override

    protected ModifiableReportConfiguration getReportConfiguration() throws IOException {

     ModifiableReportConfiguration reportConfig = ReportConfigurationFactory.createDefaultReportConfiguration();

     reportConfig.setTargetDirectory("c:\\Reports"); // The folder must exist under C:\

     reportConfig.setReportFolder("JUnitExample");

     reportConfig.setTitle("JUnit Example Run Results");

     reportConfig.setDescription("Configuration settings example");

     return reportConfig;

    }

Back to top

## Report a failure to the Run Results

This example reports a test failure to the run results.

    @Test
    	public void test() throws Exception {
    	CalculatorApp calc = new CalculatorApp();
    	try {
    		WindowDescription calculatorDescription = new WindowDescription.Builder().nativeClass("CalcFrame").build();

    		Window calculator = Desktop.describe(Window.class, calculatorDescription);

    		Button button4 = calculator.describe(Button.class, new ButtonDescription.Builder().windowId(134).nativeClass("Button").build());

    		Button buttonSqrt = calculator.describe(Button.class, new ButtonDescription.Builder().windowId(110).nativeClass("Button").build());

    		button4.click();
    		buttonSqrt.click();

    		Static textBox = calculator.describe(Static.class, new ScrollBarDescription.Builder().windowId(150).nativeClass("Static").build());
    		String visibleText = textBox.getVisibleText();

    		String expected = "2";
    		Verify.areEqual(expected, visibleText, "Expected Result Verification", "Verify the text box contains the expected text.");
    	} catch (Throwable e) {
    		Reporter.reportEvent("JUnitExample", "Test Failed", Status.Failed, e);
    		throw e;
    	} finally {
    		calc.dispose();
    	}
    }

Back to top

## Access current report status during runtime

This example shows how to access the current report status during runtime, and write different scenarios of the test execution according to the obtained value.

    Status reportStatus = Reporter.getStatus();
    if (reportStatus == Status.Passed) {
    	//continue test execution
    } else {
    	//make custom action
    }

Back to top

See also:

- Java SDK
- Java SDK code samples

https://admhelp.microfocus.com Functional Testing for Developers 8942
Tips to improve your search results... OpenText™ Functional Testing for Developers Help Center OpenText™ Functional Testing for Developers Help 25.2 All View Local Help Center View Online Help Center Version: