SpringBoot Test Framework using Serenity, Cucumber, JUnit4
- RestController is created with the name of HelloController in src/main/java
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping(path="/")
String hello() {
return "Hello World, Spring Boot!";
}
@GetMapping(path="/qaautomation")
String qaautomation() {
return "Hello QA Automation!";
}
}
- We don't want to run the application on port 8000, so we have configured port value in application.properties present in src/main/resources.
server.port=8090
- Run the below command to execute the tests and generate Serenity Report
mvn clean verify
-
Serenity Report is generated in folder target/site/serenity/index.html
-
Cucumber Report is generated by add publish=true to CucumberOptions in SpringRunnerTests
@CucumberOptions(features = "src/test/resources", tags = "",
glue = "com.example.Springboot_Serenity_Demo.definitions", publish = true)