SE 3800 Exercise 2: Adding Feature Files to Cucumber Tests

In this exercise you will get experience with writing simple Cucumber tests and the step definitions to support those tests. The starting point is the project at https://gitlab.com/hasker/cucumber-phonebook You will modify and add a few files to this project for the exercise. You can use Docker in a VM to test your changes, or you can use GitLab's CI to do the tests for you. There will be no evidence document since the GitLab CI system will capture everything needed for grading. You will submit your revised feature and step definition file to simplify grading and so I know when you are done.

Steps:
  1. Create an empty repository in Gitlab under msoe.edu > se > se3800f22 using the name cuke_username where username is replaced by your username.
  2. Clone your (empty) repository to some convenient place on your laptop.
  3. Clone the cucumber-phonebook project into another location:
            git clone https://gitlab.com/hasker/cucumber-phonebook.git
    
    and move the files - except the old .git folder! - to your own repository. The new files should be at the top of your repository! In particular, make sure .gitlab-ci.yml, .gitignore, Dockerfile, and pom.xml are all in the root of your project. Note the project Readme file contains more detail about running the code, but you do not have to read through this to complete the lab.
    • NOTE: GitLab creates a default .gitlab-ci.yml file. You must replace it by the file I distribute for CI to work correctly.
  4. Add, commit, push the files to your repository.
  5. Modify src/test/resources/pbook_command_tests/remove_phone.feature by adding a step to remove Zoe (using appropriate text such as "When I remove Zoe") and uncommenting the step to check the number of entries is 0.
  6. By now the first CI run will be completed on GitLab; confirm that all tests passed.
  7. Without making further changes, push the change to remove_phone.feature. This CI build will fail indicating there is no step definition for the remove operation.
  8. Modify src/test/java/pbook_tests/AddStepDefinitions.java to add a step definition for the remove command. See do_add for the pattern, noting from the project Readme that the remove operation will only ask for the person's name (not a phone number). This step will have no assertions since it simply emulates the action done by the user.
  9. Confirm the tests pass. If you are using GitLab to run your tests (as opposed to running them locally), you can probably go to the next step while GitLab does its work.
  10. Add a scenario to the features file to add two phone entries, remove the first, and confirm there is just one item in the phonebook.

A weakness of the provided scenarios is that if the wrong entries are removed from the phonebook (using either remove or undo after an add), the tests will not identify the problem. For 5 points of extra credit on the lab (assuming the rest of the lab is done correctly), you can add a step definition for looking up names in the phonebook (the get command) and use this to confirm that the correct entries have been removed in the other commands. This will require changing add_phone.feature as well. Be sure to write at the top of add_phone.feature that the code tests the contents as well; make sure this remark is prominent to get your extra credit.

Submission

  1. Ensure all tests pass in your final push to GitLab.
  2. In Canvas, submit your revised .feature and .java files.
  3. You may work with others on this assignment, but you must submit your own solution to GitLab and Canvas. The coding standard does not apply to this exercise.