CSC/ECE 517 Spring 2018/E1814 Write unit tests for collusion cycle.rb

From Expertiza_Wiki
Revision as of 02:31, 27 March 2018 by Rjmontgo (talk | contribs) (→‎Team)
Jump to navigation Jump to search

Introduction

Team

  • Cameron Nelson (cenelso3)
  • Peter Shore (pnshore)
  • Robert Montgomery (rjmontgo)

Zhewei Hu (zhu6) (mentor)

Background

Expertiza is an open source project that can be used by instructors to create assignments and assign them to students. Students can manage teams for the assignment and submit work for each of the assignments. After the students have submitted their work they can review other student's work to facilitate grading. The project is based on the Ruby on Rails framework. You can find our GitHub Repo to view our work.

Motivation

Achieving good coverage with quality tests is part of a good development process. The collusion_cycle.rb class is used to calculate the grade received based on the reviews from other students as well as handle cases where the reviewer is also reviewed by the reviewee effectively creating a cycle. We want to test this class to achieve good coverage in order to catch possible bugs in the program and ensure that it works correctly.

Tasks Identified

  • Test Two Node Cycle
  • Test Three Node Cycle
  • Test Four Node Cycle
  • Test Cycle Similarity Score
  • Test Cycle Deviation Score

Classes

app/models/collusion_cycle.rb

spec/models/collusion_cycle_spec.rb

Writing the collusion Cycle Tests

To start the test file we created sample data through FactoryBot to aid testing through each of the tasks we identified. To test each of the Node Cycle tests we created a context for each of the possible branches in a node cycle to ensure that we tested all branches thoroughly. To test the Cycle Similarity Score and Cycle Deviation Score we will again create sample data and pass it to each of the functions to make sure we get the appropriate grade from the collusion of each of the reviewers.

Changes To the View

None

Impact Analysis

Currently, we have already found one bug, which was a missing parameter in the collusion_cycle.rb file with each of the node_cycle methods (two_node_cycle, three_node_cycle, four_node_cycle) which needed an assignmentparticipant parameter to be passed in for the function to even work. In addition the obvious benefit of adding more coverage you a better assurance that the code works well. Of course testing does not guarantee that the code works, but can only be used to find where the code does not work.

Running the Test Files

To run the test files you need to clone the repository in an Expertiza environment Expertiza Github. Instructions for creating an appropriate Expertiza environment can be found in the README file in the Expertiza GitHub repository.

Once you have the Expertiza repository setup make sure you are in the root directory of the app and run `rspec spec/models/collusion_cycle_spec.rb`

Future Work

Because the scope of this addition is relatively small, and we have tested all possible branches within the code there is not much future work to do other than possibly refactor the code with a more efficient tool. Test coverage through quality tests consistently added throughout the development of the Expertiza project should be the future work of the project.