Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Jbehave- Basics to Advance

659 views

Published on

It briefs all the details needed for learning JBehave + Serenity

Published in: Software

Jbehave- Basics to Advance

  1. 1. Testing Pyramid
  2. 2. TDD
  3. 3. Acceptance TDD vs Developer TDD
  4. 4. BDD
  5. 5. Why BDD
  6. 6. What’s Changed
  7. 7. QA Myths  You only need to unit test. TDD testing is sufficient.  You can reuse unit tests to build a regression test suite.  We no longer need testers, as Developer have adequate coding skills.  Unit test remove the need of manual testing.  User Acceptance testing is no longer needed.  Automation in so early phases is impossible.  TDD/BDD is applicable on every project.  Developers and testers are like water and oil.
  8. 8. Unit Testing Frameworks in Java  JUnit  Cactus  StrutsTestCase  TestNG  jMock  Grinder  Jetif  Unitils  p-unit  XMLUnit  Ejb3Unit  FEST-Swing  Ripplet  Feed4JUnit  ...
  9. 9. Junit vs TestNG
  10. 10. JUnit  @Test Annotation  JUnitCore  Exception Test  @Ignore  Timeout Test  TestSuite  Before and After Annotations  @BeforeClass and @AfterClass  Parameterized Test
  11. 11. TestNG  Annotations  Exception Test  Ignore Test  Timing Test  TestSuite  Parameterized Test  Test Dependency  Group Test and Dependency
  12. 12. Maven  JUnit + Maven  TestNG + Maven
  13. 13. 1. Write Story  Create New Maven project using MyNumber class used in previous examples.  Add Jbehave plugin in IntelliJ  Add dependencies of Jbehave and Junit  Add a new story under test resources folder
  14. 14. 2. Map Steps to Java  Create a POJO and implement the Given, When, Then Steps
  15. 15. 3. Configure Stories  Implement a TestRunner class by extending class JUnitStory.  Override the configuration and stepsFactory methods.  Ensure that story name would be same as test name with _ updated for each Camel Case.  This is because of the configuration used for loading of story, i.e., MostUsefulConfiguration
  16. 16. 4. Run the Story  Run the story same as Junit test
  17. 17. 5. View Reports  Verify the reports under target/jbehave folder
  18. 18. JUnit-enabled Embeddables  JUnitStory: provides a one-to-one mapping with the textual story.  JUnitStories: provides a many-to-one mapping with the textual story paths
  19. 19. Story Syntax  JBehave Syntax  Narrative:  Lifecycle:  Before:  After  Scenario  Gherkin Syntax  Narrative:  Background:  Given:  Scenario/Scenario Outline: Gherkin's Background element corresponds to the JBehave Lifecycle Before element. JBehave also supports a Lifecycle After element which is not currently available in Gherkin.
  20. 20. Annotations  Step Annotations.  @Given  @When  @Then  @Alias  @Aliases  @Pending  Scenario Annotations.  @BeforeScenario  @AfterScenario  Story Annotations.  @BeforeStory  @AfterStory  Stories Annotations.  @BeforeStories  @AfterStories  Parameter Annotations.  @Named
  21. 21. Step Annotations  @Given  @When  @Then  @Alias  @Aliases  @Pending Dry Run Mode Check if any steps are pending but without actually executing any of the steps
  22. 22. Scenario Annotations  @BeforeScenario  @AfterScenario
  23. 23. Story Annotations  @BeforeStory  @AfterStory
  24. 24. Stories Annotations  @BeforeStories  @AfterStories
  25. 25. Parameter Annotations  @Named
  26. 26. Prioritizing Steps  For cases in which multiple candidates can match the same textual step, the first candidate that matches is used to create an executable step.  To prioritize one candidate over another simply set a non-zero positive priority.
  27. 27. Story Path’s  Class-path – Arrange in any folder hierarchy within project.  URL-Loader (Running Remote Stories) – Specify the path from a URL  Google-docs (Running Remote Stories) – No more supported, due to change in google authorization, but can be customized, if needed for a project.
  28. 28. Reporting  ConsoleOutput  IdeOnlyConsoleOutput  TxtOutput  HtmlOutput  HtmlTemplateOutput  XmlOutput
  29. 29. Customizing Reports  Specify the FTL File  Define a custom Template that will use the FTL file  Use this reporter in TestRunner
  30. 30. UI Testing  Use Serenity Stories  Specify properties in serenity.properties or from maven command line options  Specify “aggregate” goal to aggregate reports.
  31. 31. REST APIs Testing  Use plugin serenity-rest-assured to invoke rest APIs
  32. 32. CI Setup - Jenkins  Download Jekins from https://jenkins.io/download/  Install Jenkins.

×