CSC/ECE 517 Fall 2020 - E2062. Add test cases to review mapping helper.rb

From Expertiza_Wiki
Jump to navigation Jump to search

Project Introduction

The ReviewMappingHelper is a helper class that is responsible for mapping reviews and feedback to reviewers and assignment teams. Additionally, this helper class reports of the status of project reviews.

Team

Courtney Ripoll (ctripoll)

Rohit Nair (rnair2)

Prasanth Yadla (pyadla2)

Project Goal

The goal of this project was to add RSpec tests for the functionality added for project CSC/ECE 517 Fall 2019 - E1948. Refactor review mapping helper.rb. The changes submitted by project E1948 can be found here. See the Test Outline section to see the specifics of our testing work.

Files Involved

review_mapping_helper.rb

review_mapping_helper_spec.rb

Running Tests

  rspec spec/helpers/review_mapping_helper_spec.rb

Test Plan

For this project, our plan was to write new RSpec tests for new methods added in project E1948 for ReviewMappingHelper. In total, our team wrote 34 tests to cover the 8 new methods created or altered methods. These 8 methods are listed below. See the Test Outline for more details on the RSpec tests written these methods.

ReviewMappingHelper Relevant Methods

  • get_review_volume
  • get_team_color
  • obtain_team_color
  • link_updated_since_last?
  • get_each_review_and_feedback_response_map
  • get_awarded_review_score
  • check_submission_state
  • feedback_response_map_record
  • get_team_color

Test Outline

This section shows the RSpec test we created for each of the methods defined in Relevant Methods above. The full test file can be found here.


get_team_color

This method gets the team name's color according to review and assignment submission status. The RSpec tests for this method interact with an assignment to test if it results in an appropriate review/feedback status color, depending on which actions were taken. Before any of those tests are executed, the RSpec feature first sets up an assignment, a reviewer, and a reviewee (A reviewee is a user who worked on the assignment). Some tests stray away from the preset variables as some tests aim to target use cases where an assignment or reviewer might have special attributes.

Setup

Tests

get_each_review_and_feedback_response_map

This method gets review and feedback responses for all rounds for the feedback report. Before testing this method, RSpec sets up an assignment, a review, and a reviewee. Then it creates 2 responses from the reviewer (one for each of the initial 2 rounds). During testing, these RSpec tests assures this method returns the correct amount of responses for each round. In this scenario created, each round should return 1. There is an additional two tests in this RSpec feature, testing to see if a 3rd round returns nothing if there was no response created (which there is not a 3rd response pre-setup. Likewise, there is an additional test where it creates a third response and assures that this method returns 1 for round 3.

Setup

Tests

get_awarded_review_score

This method gets the review score awarded based on each round of the review. Before testing this method, RSpec sets up an assignment, a reviewer, and a reviewee. Then it assignments 3 scores (one for each round) given by the reviewer. During testing, these RSpec tests check to see if this method returns the correct awarded score for each round requested.

Setup

Tests

check_submission_state

This method checks the submission state within each round and assigns team color accordingly. The check_submission_state method calls the submitted_within_round? method to check if the submission was made in the current round and if yes then the purple color will be assigned to the team. One of the test cases tests this feature that purple color is being set or not. If no link was included by the team in the submission or the link is not a wiki link or the assignment was not submitted within the round, then the team will be assigned green color. These conditions are also being covered in the tests below.

Setup

Tests

feedback_response_map_record

This method is a helper method for get_each_review_and_feedback_response_map. It sets the instance variables @review_responses_round_ and @feedback_response_maps_round_ after calculating the number of responses received by the team after each round. This method should return the corresponding response map associated with each round of review. The initial setup to test this method includes creating a reviewer, creating responses and review_response_map_ids. The tests check if the correct response map is returned or not for each round.

Setup

Tests

get_review_volume

This method is a helper method for _team_score.html.erb view. It sets the metrics, namely min, max and avg score value for all reviews for a particular round and team. It uses the pre-populated instance variable @avg_and_ranges and makes new instance variables @min, @max, @avg and sets the latter values to the corresponding value from the former. In the setup for the Rspec test, we create assignment, due dates for 3 rounds, student, reviewee, reviewer and user. Since the method requires @avg_and_ranges for lookup, we hardcode values as explained previosly. In each of the test cases, we assert for the @min, @max, @avg instance variables with our hardcoded values initially setup in @avg_and_ranges. If the assertions pass, it means that the method successfully looked up @avg_and_ranges and set the corresponding values to @min, @max, @avg. We have 3 test cases each for round 1, round 2 and round 3.

Setup

Tests

link_updated_since_last?

This methods checks if the link submitted for evaluation has been updated or not since the last round. The method takes in parameters round, due date and link updated time and compares the dates to check whether the latter for before the former time. The method returns false if it's not updated and true otherwise. The setup for this rspec test included creating an assignment and creating 2 rounds with corresponding due dates along with a reviewer and reviewee for the same. The first test case asserts that the method returns false when link is not updated. The second test case asserts that the method returns true when the link is updated within the due date.

Setup

Tests

obtain_team_color

This method calls check_submission_state to get the color in each of rounds and returns the value of the color at the end of the stack accumulated. In the setup for this Rspec tests, we create an assignment along with the reviewee and reviewer. As per the logic of source code, the first test case asserts whether purple color is returned if the assignment was submitted in the current round but not submitted in the previous round. Another test case asserts that green is returned when there was no submission in any round. The remaining 2 test cases asserts whether the methods works as expected for a 4-round case as well as a 3-round case.We create and vary the expected parameters (submission record, due_date) of the method in each test case.

Setup

Tests

Results

34 out of 34 tests in the review_mapping_helper_spec.rb test file.

Our code changes can be viewed here.

URL link of video of review_mapping_helper_spec.rb tests running and passing:- https://drive.google.com/file/d/1OS4yNI0fDGo4TlkOSxuWNgfMZ4D-XU2f/view

Relevant Links

Main Expertiza Repository can be found here.

Our forked Repository can be found here.

Extra Tasks

In addition to adding new test cases to ReviewMappingHelper, we implemented two other changes to the Expertiza code.

Refactoring Methods

  • We refactored get_review_metrics to get_review_volume, as per request from the professor

  • We refactored get_team_colour & obtain_team_colour to read get_team_color & obtain_team_color, as per request from the professor

  • We refactored calcutate_average_author_feedback_score to calculate_average_author_feedback_score, as per request from the professor

Fixing Code

  • The use of the "dig" method in Expertiza was causing failures in the Travis build because the "dig" method is supported after ruby version 2.3 and expertiza uses ruby version 2.2.7. We fixed this by replacing "dig" with an equivalent dictionary accessing code in the methods get_awarded_review_score and get_review_volume.