Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects

Create tutorial on BDD

Merged Daya Adianto requested to merge chore/10-bdd-tutorial into main
All threads resolved!
1 file
+ 16
27
Compare changes
  • Side-by-side
  • Inline
+ 16
27
@@ -141,8 +141,8 @@ One of the advantages of following this format is that the test scenario can be
They can focus on writing the test scenario without worrying about the implementation details.
Eventually, there needs some way to "glue" the test scenario into the actual test code.
That is, the test scenario that is written in Gherkin format drives the test procedures in the test code.
To achieve that, we will write the "glue" code and also apply two patterns relevant to our need:
That is, the test scenario that is written in Gherkin syntax drives the test procedures in the test code.
To achieve that, we will write the "glue" code and apply two patterns relevant to our need:
Screenplay & Page Object Model (POM).
> Note: There also exists the equivalent keywords in other languages such as Bahasa Indonesia.
@@ -155,9 +155,6 @@ Screenplay & Page Object Model (POM).
We use the Page Object Model pattern to represent the significant elements of the user interface (UI)
(i.e. the HTML elements) in a more readable and reusable way for the test code.
While we can use the selector method provided by Selenium or Selenide to obtain the reference to a UI element,
it is more preferred to follow the Page Object Model since the BDD test scenarios has to be writable and readable both
by technical (e.g. developer, QA) and non-technical (e.g. user, business analyst) roles.
> TODO: Page Object Model
@@ -256,37 +253,29 @@ or to cover other possible outputs.
- Try to add new todo items and mark their completion status
- See how the motivation message is updated based on the number of completed todo items
- [ ] Run the test suites locally, ensure all test passes
- [ ] Write two test scenarios for "see motivation message" feature
- [ ] Write two test scenarios for "mark a todo item" feature
- [ ] Write the required "glue" code to support the new test scenarios
- [ ] Summarise the whole process and write them in a `summary.md`. Write an analysis of what you did and what you learned from this exercise. Please provide screenshot for each test scenario
- [ ] Write a new executable specification for "see motivation" feature that contains at least two test scenarios
- [ ] Write a new executable specification for "mark a todo item" feature that contains at least two test scenarios
- [ ] Write the required "glue" code to support the new executable specifications
- [ ] Maintain code coverage greater than or equal to 97%
- [ ] Summarise the whole process and write them in a `summary.md`
- Write an analysis of what you did and what you learned from this exercise and please include the test reports
> Note: You are allowed to modify the production code (i.e. the `src/main/java` directory) to make your test code can obtain the reference to the UI elements in the page.
> For example, you can add a new HTML attribute, CSS class, or CSS id to an element in the page to make it easier to be located.
> For example, you can add a new HTML attribute, CSS class, or CSS id to an element in the page to make it easier to be located by selector methods.
### Additional Tasks
- [ ] Maintain code coverage greater than or equal to 97%
- [ ] Implement an error handling when posting an empty todo item. Create a test scenario for this error-handling
- [ ] Implement the error handling when posting an empty todo item by following TDD approach in BDD (also known as: outside-in TDD)
- Start by writing the executable specification that describes the error handling
- Then, implement the error handling by following TDD approach (i.e. red-green-refactor phases)
- Ensure the error handling works
- Finally, demonstrate that both the unit and BDD test suites run successfully
- [ ] (Not Graded) Deploy the app to a cloud platform and run the BDD test suite by targeting the deployed app
> Outline:
> - Gherkin format (Given-When-Then) as executable scenarios
>
> - Glue code, step definitions
> - Screenplay & Page Object pattern
>
> Quotes:
>
> - Ideally, if all of the acceptance criteria for a feature have been automated and run successfully, you can say that this feature is finished and ready for production.
>
> References:
> - https://livebook.manning.com/book/bdd-in-action-second-edition/chapter-8
> - See chapter 8.5.1 of the BDD reference book to learn how to perform setup & teardown phase in BDD test.
>
> Draft Scenario for additional task: Todo item cannot be empty
>
> - Given Alice is looking at the todo list
> - When she accidentally adds an empty item
> - Then she should be presented with a warning message containing "Todo item cannot be empty"
## License
Loading