diff --git a/docs/2024/exercise2.md b/docs/2024/exercise2.md new file mode 100644 index 0000000000000000000000000000000000000000..2969461f4f9bf9dec4dbc6ba2683023cb27430f7 --- /dev/null +++ b/docs/2024/exercise2.md @@ -0,0 +1,131 @@ +# Exercise 2: Input Space Partitioning & Control Flow Graph + +You are asked to design an input domain model (IDM) and a control flow graph (CFG) for testing the [Spring Petclinic Rest][Spring Petclinic Rest] project. +Specifically, you need to create IDM and CFG for designing the test cases for testing at least **two methods** listed in [To Model](#to-model) section. + +After you have designed the IDM and CFG, you need to define the test requirements based on each model by using a coverage criteria of your choice such as Base Choice Coverage (for IDM) and Edge-Pair Coverage (for CFG). Based on the test requirements, you need to design the test case values from the IDM and the test paths from the CFG that will satisfy the test requirements. + +You can use a template for the IDM that is available in [Markdown](#appendix-1-markdown-template) or [Microsoft Word](https://pmpl.cs.ui.ac.id/2021/resources/exercise2-template.docx). As for the CFG, there is no template. You can use image editor or diagram tool to create the CFG. Do not forget to include the CFG drawing into the written report. + +Finally, show that there is **at least one test value** and **at least one test path** derived from the corresponding models that will satisfy the existing JUnit test suite in the project. If there are no test cases in the test suite that have been satisfied by the test value and test path, you need to update the existing JUnit test suite by adding new test cases as JUnit test methods. + +> Notes: We provide an [IDM example from past exercise](https://pmpl.cs.ui.ac.id/2021/resources/exercise2-idm_example.pdf) if you require a reference on how to create an IDM. + +## To Model + +The following is a list of methods that can be modeled into IDM and CFG in this exercise: + +- `getOwnersPet` method in `OwnerRestController` class. +- `updateVet` method in `VetRestController` class. +- `saveUser` method in `UserServiceImpl` class. + +You only need to pick **two methods** out of three to model into IDM and CFG. + +## Preparatory Tasks + +1. [ ] Fork the [Spring Petclinic Rest][Spring Petclinic Rest] repository to your own account on GitLab CSUI. +2. [ ] Clone the Git repository of the new fork into your local development machine. +3. [ ] Open the cloned Git repository as a project using your favourite text editor or IDE that supports Java-based project. +4. [ ] Create a new branch named `exercise2` from the `csui` branch of your cloned fork. +5. [ ] Choose two methods from the codebase that you want to model. + +## IDM Tasks + +For each method you picked: + +1. [ ] Create the IDM + > Please choose whether to follow interface-based (syntax) + or functionality-based approach (behaviour) for each method when trying to identify the characteristics and their partition. +2. [ ] Identify the constraints among characteristics, if exists. + > Remember that specifying constraints in the IDM can help filtering out unfeasible test values values from being picked up, thus may reduce the number of possible test cases. +3. [ ] List the test requirements using the **Base Choice Coverage** criteria. +4. [ ] Determine the test values that satisfy the test requirements. +5. [ ] Associate at least one test value to their corresponding test case method in the existing JUnit test suite + and briefly explain the reason (at most 3 sentences). +6. [ ] If you cannot find a test value that corresponds to any of the test case method in the existing test suite, + update the existing JUnit test suite by adding a new test case method that corresponds to a test value in your model. Then, briefly explain your justification why the new test case method satifies the chosen test value (at most 3 sentences). +7. [ ] Commit and push your changes to your fork on GitLab CSUI. + +## CFG Tasks + +For each method you picked: + +1. [ ] Create the CFG +2. [ ] List the test requirements using the **Edge-Pair Coverage** criteria. +3. [ ] Determine the test paths that satisfy the test requirements. +4. [ ] Associate at least one test path to their corresponding test case method in the existing JUnit test suite + and briefly explain the reason (at most 3 sentences). +5. [ ] If you cannot find a test path that corresponds to any of the test case method in the existing test suite, + update the existing JUnit test suite by adding a new test case method that corresponds to a test path in your model. Then, briefly explain your justification why the new test case method satisfies the chosen test path (at most 3 sentences). +6. [ ] Commit and push your changes to your fork on GitLab CSUI. + +## Deliverables + +At the end of this exercise, you are required to prepare the following +artifacts: + +- [ ] A fork repository of [Spring Petclinic Rest][Spring Petclinic Rest] in your own namespace on GitLab CSUI. +- [ ] A written report in a Markdown file named `EXERCISE_2_REPORT.md` or Word file named `EXERCISE_2_REPORT.docx` in the fork repository. The report must contain the following: + - The IDM and CFG for each method you choose to model. + - The test requirements for each chosen method derived from their IDM and CFG. + - The test values and test paths for each chosen method. + - Your reasons when associating a test value and a test path to their corresponding test case method. + - Similarly, your reasons why creating a new test case method to satisfy a test value and a test path. +- [ ] An updated JUnit test suite if you created new test case methods. + +The due date of this exercise is: **22 November 2023, 23:55 UTC+7**. +Submit the URL of your fork repository to the designated submission slot on SCELE. +Please ensure any updates to the fork repository related to this exercise were made +and pushed before the due date. + +## References + +- [Ch 6. Input Space Partitioning slide at Paul Amman's Introduction to Software Testing book website](https://cs.gmu.edu/~offutt/softwaretest/powerpoint/Ch06-ISP.pptx) +- [6.005 — Software Construction on MIT OpenCourseWare | Reading 3: Testing](https://ocw.mit.edu/ans7870/6/6.005/s16/classes/03-testing/index.html) + +## Appendix 1: Markdown Template + +You can use the following Markdown template to document the IDM in your +`EXERCISE_2_REPORT.md` file: + +```markdown +# ISP Documentation for [Insert Function Name Here] + +## Input Domain Model + +| Characteristics | b1 | b2 | ... | +|------------------|---------------|---------------|-----| +| Characteristic A | Partition A 1 | Partition B 2 | | +| Characteristic B | Partition B 1 | ... | | +| ... | ... | ... | | + +Note: You can write some explanation about how you design your IDM to help you +during demonstration. + +## IDM Relabeling Table + +| Characteristics | b1 | b2 | ... | +|-----------------|-----|-----|-----| +| A | A1 | A2 | | +| B | B1 | ... | | +| ... | ... | | | + +## Constraints + +- Constraint 1 +- Constraint 2 +- ... + +## Test Values and Example I/O + +Criteria Used: [Define your chosen criteria here] + +| Test Value | Example Input | Expected Output | +|------------|---------------|-----------------| +| A1B1... | Input 1 | Output 1 | +| A1B2... | Input 2 | ... | +| ... | ... | ... | + +``` + +[Spring Petclinic Rest]: https://gitlab.cs.ui.ac.id/pmpl/examples/spring-petclinic-rest diff --git a/mkdocs.yml b/mkdocs.yml index d8b3ccf1857901176ffae9a7982df686c116af71..f778bb204d035a2b60566cd7ac9423861a202b83 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -59,6 +59,7 @@ nav: - Docker Installation: workshops/prep.md - Problem Set: - (2024) Exercise 1 - Automated QA: 2024/exercise1.md + - (2024) Exercise 2 - Input Domain Modeling & Control Flow Graph: 2024/exercise2.md - (2023) Exercise 1 - Automated QA: 2023/exercise1.md - (2023) Exercise 2 - Input Domain Modeling: 2023/exercise2.md - (2023) Exercise 3 - Monitoring & Load Testing: 2023/exercise3.md