Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

How to integrate Serenity Screenplay?


#1

Hi, we are new to TestRail, and are implementing a new Serenity BDD automation project using the Screenplay pattern. I have gotten the TestRail API’s to work by sending a pass/fail code to TestRail. However, thus far I have only been able to figure out how to send a hard-coded result. What I’m struggling with is figuring out how to capture the actual test result code from Serenity to send to TestRail.

Here’s what I have so far. The following code snippet will send a failure code to TestRail if the script crashes for some reason, and a pass code at the end of the test. The problem is that if the test is a legit fail, this will still send a pass code at the end. So if, at the end of this test, the page title does not equal “The Page Title”, then the Serenity test fails, but it’s still going to send a pass code to TestRail. Somehow I need to grab the actual test result code from Serenity and send that.

@Test
public void login_logout() throws Exception {
try{
givenThat(theUnderwriter).wasAbleTo(doSomething);
when(theUnderwriter).attemptsTo(doSomethingElse);
then(theUnderwriter).should(seeThat(thePageTitle, containsText(“The Page Title”)));
} catch (Exception e) {
System.out.println(“Test failed”);
setTestCaseResult(testCaseID, testRunID, 5); // Failed
}
}

@After
public void wrapUp() throws Exception {
setTestCaseResult(testCaseID, testRunID, 1); //Passed
}