CSC/ECE 517 Fall 2021 - E2133. Write tests for popup controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
The goal of this project is to add unit testing for the PopupController to raise statement coverage above 60%. See the Test Outline section for specifics of our work.
== Project Introduction ==
== Project Introduction ==
The PopupController is responsible for preparing data that will be displayed in popup views. To render the data, which mostly concerns assignments, the controller makes many accesses to database tables such as Response, ResponseMap, Question, Questionnaire, Answer, and Participant.  
The PopupController is responsible for preparing data that will be displayed in popup views. To render the data, which mostly concerns assignments, the controller makes many accesses to database tables such as Response, ResponseMap, Question, Questionnaire, Answer, and Participant. The previous team implemented some of the test cases to improve the coverage. The previous work test coverage was 96%. However, their test cases followed integration testing methodologies which were not consistent with Unit testing.
We will be implementing Unit testing while retaining the current coverage.


=== Team ===
=== Team ===
Yi Qiu (mentor)


*Sayali Parab, snparab1704
*Sayali Parab, snparab1704


*Rageeni  
*Rageeni Sah, ragesah


*Priya
*Priya Jakhar, priyajakhar


=== Files Involved ===  
=== Files Involved ===  
Line 17: Line 21:


=== Running Tests ===
=== Running Tests ===
What we need to do is to set up the environment and complete the 'popup_controller_spec.rb' to finish the integration tests for popup controller. This rspec test file can be run by calling the following code:  
What we need to do is to set up the environment and complete the 'popup_controller_spec.rb' to finish the unit tests for popup controller. This rspec test file can be run by calling the following code:  
<pre>
<pre>
   rspec spec/controllers/popup_controller_spec.rb
   rspec spec/controllers/popup_controller_spec.rb
Line 23: Line 27:


===What needs to be done===
===What needs to be done===
1.Write RSpec integration tests to make the statement coverage above 90%.
1. Write RSpec unit test cases to make the statement coverage above 90%.
 
2.Cover as many edge cases as you can.


3.Achieve as high branch coverage as you can. Teaching staff will use the mutant-rspec gem to measure test thoroughness and fault-finding capability of tests.
2. Cover as many boundary cases and the core functionality for all popup controller actions.




== Test Plan ==
== Test Plan ==
In total, we wrote tests to cover all 6 methods in the popup controller. We created unit test cases with the help of mocked objects (factory objects and stub objects).




Line 43: Line 46:
*reviewer_details_popup
*reviewer_details_popup
*self_review_popup
*self_review_popup
====Mock Models====
====Test Frame====
Since it's unit testing, we need to test functional logic.
1. *action_allowed?
Functionality :
Test case :
2.
== Results ==
The total coverage of the test is 63.29%, meeting our minimum coverage requirement.





Revision as of 21:12, 20 October 2021

The goal of this project is to add unit testing for the PopupController to raise statement coverage above 60%. See the Test Outline section for specifics of our work.

Project Introduction

The PopupController is responsible for preparing data that will be displayed in popup views. To render the data, which mostly concerns assignments, the controller makes many accesses to database tables such as Response, ResponseMap, Question, Questionnaire, Answer, and Participant. The previous team implemented some of the test cases to improve the coverage. The previous work test coverage was 96%. However, their test cases followed integration testing methodologies which were not consistent with Unit testing. We will be implementing Unit testing while retaining the current coverage.

Team

Yi Qiu (mentor)

  • Sayali Parab, snparab1704
  • Rageeni Sah, ragesah
  • Priya Jakhar, priyajakhar

Files Involved

popup_controller.rb

popup_controller_spec.rb

Running Tests

What we need to do is to set up the environment and complete the 'popup_controller_spec.rb' to finish the unit tests for popup controller. This rspec test file can be run by calling the following code:

  rspec spec/controllers/popup_controller_spec.rb

What needs to be done

1. Write RSpec unit test cases to make the statement coverage above 90%.

2. Cover as many boundary cases and the core functionality for all popup controller actions.


Test Plan

In total, we wrote tests to cover all 6 methods in the popup controller. We created unit test cases with the help of mocked objects (factory objects and stub objects).


Popup Controller Methods

The code of the controller can be found here. The methods are:

  • action_allowed?
  • author_feedback_popup
  • team_users_popup
  • view_review_scores_popup
  • reviewer_details_popup
  • self_review_popup

Mock Models

Test Frame

Since it's unit testing, we need to test functional logic.

1. *action_allowed? Functionality :

Test case :

2.

Results

The total coverage of the test is 63.29%, meeting our minimum coverage requirement.


Related Links

The main repository can be found here

The forked git repository for this project can be found here

Conclusion