CSC/ECE 517 Fall 2017/E1762 Test various kinds of response-map hierarchies: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 63: Line 63:


• Global_survey_response_map_spec.rb
• Global_survey_response_map_spec.rb
=='''Creating Factories'''==
Each response map model needs its own factory for testing to create relevant mock objects to test the specs written. Hence here is a sample of a factory we created for the response_map.rb model.
factory :response_map, class: ResponseMap do
    reviewed_object_id 1
    reviewer_id 1
    reviewee_id 1
    type 'ResponseMap'
    calibrate_to 0
  end

Revision as of 03:30, 28 October 2017

Expertiza Background

Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and edit assignments to Expertiza. Students can be assigned in teams based on their selection of the topics. The Expertiza project is supported by the National Science Foundation. The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.

Introduction

Problem Statement

In Expertiza, there are several types of response maps (model files in app/models). They basically map responses, the one who submitted the response and the one to whom it is directed to. The parent class is ResponseMap, and the subclasses are (from most used to least used) ReviewResponseMap, TeammateReviewResponseMap, FeedbackResponseMap, QuizResponseMap, AssignmentSurveyResponseMap, BookmarkRatingResponseMap, MetareviewResponseMap, SelfReviewResponseMap, CourseSurveyResponseMap, GlobalSurveyResponseMap. You can find the database structure for these response maps here. For each response map record, there is one reviewer_id and reviewee_id. However, you need to check the code to learn what are recorded as reviewer/reviewee ids (see the foreign key constraints at the beginning of each model, they could be participant_id, team_id, etc. as per that model). These models do not have any unit tests.


Work to be done

• Create a factory for each response map models in factories.rb file (review_response_map factory has already existed).

• Then create test files in spec/models (you can refer to answer_spec.rb, due_date_spec.rb for how to write specs); write model specs for methods (if you find any method has no caller, remove the method instead of write tests for it). Good tests means their coverage is maximum, so try to cover as much methods and conditions as possible. ---

Files to be used or created

To write the unit tests for the models, we need to define the spec files for the models. But before that, we need to understand the working of the methods. For this we use the following files (in app\models) –

• Response_map.rb

• Review_response_map.rb

• Teammate_review_response_map.rb

• Feedback_response_map.rb

• Quiz_response_map.rb

• Assignment_survey_response_map.rb

• Bookmark_rating_response_map.rb

• Metareview_response_map.rb

• Self_review_response_map.rb

• Course_survey_response_map.rb

• Global_survey_response_map.rb

While writing our tests we will need a way to set up database records in a way to test against them in different scenarios. This is done by creating factories for each response map model in the spec/factories/factories.rb file.

Now, we use RSpec to create the test cases for these models. These files are added in the spec/models/ folder. The convention of naming the files is MODELNAME_spec.rb, hence we get following files.

• Response_map_spec.rb

• Review_response_map_spec.rb

• Teammate_review_response_map_spec.rb

• Feedback_response_map_spec.rb

• Quiz_response_map_spec.rb

• Assignment_survey_response_map_spec.rb

• Bookmark_rating_response_map_spec.rb

• Metareview_response_map_spec.rb

• Self_review_response_map_spec.rb

• Course_survey_response_map_spec.rb

• Global_survey_response_map_spec.rb

Creating Factories

Each response map model needs its own factory for testing to create relevant mock objects to test the specs written. Hence here is a sample of a factory we created for the response_map.rb model.

factory :response_map, class: ResponseMap do

   reviewed_object_id 1
   reviewer_id 1
   reviewee_id 1
   type 'ResponseMap'
   calibrate_to 0
 end