CSC/ECE 517 Fall 2019 - E1955.Write unit tests for student task.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 16: Line 16:


The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added.The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.
The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added.The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.
There are few tests for student_task.rb. We had to test the following functions:
complete?
content_submitted_in_current_stage?
hyperlinks
in_work_stage?
incomplete?
metareviews_given?
metareviews_given_in_current_stage?
not_started?
relative_deadline
reviews_given?
reviews_given_in_current_stage?
revision?
from_participant(participant)
from_participant_id(id)
from_user(user)
get_author_feedback_data(participant_id, timeline_list)
get_due_date_data(assignment, timeline_list)
get_peer_review_data(participant_id, timeline_list)
get_submission_data(assignment_id, team_id, timeline_list)
get_timeline_data(assignment, participant, team)
teamed_students(user, ip_address = nil)
started?
topic_name
[edit]Overall tasks


=== Team ===
=== Team ===

Revision as of 19:24, 26 October 2019

This page provides a description of the Expertiza based OSS project.


About Expertiza

Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.

This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.


About RSpec

RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xUnit frameworks like JUnit because RSpec is a Behavior driven development tool. What this means is that, tests written in RSpec focus on the "behavior" of an application being tested. RSpec does not put emphasis on, how the application works but instead on how it behaves, in other words, what the application actually does.Each RSpec file contains one or more tests. Each test ensures if a particular feature of our website is working properly.The output of an RSpec run will tell you exactly what features aren't working. The benefit is that tested code is unlikely to break unnoticed.The tests are run every time someone makes, or updates, a Pull Request.

Description of the current project

The following is an Expertiza based OSS project which deals primarily with the student_task.rb and student_task_spec.rb. It focuses on writing RSpec unit tests for the code affected or added.The goal of this project is to attempt to add sufficient unit tests to this part of the application and increase its path coverage to above 90 percent.

There are few tests for student_task.rb. We had to test the following functions:

complete? content_submitted_in_current_stage? hyperlinks in_work_stage? incomplete? metareviews_given? metareviews_given_in_current_stage? not_started? relative_deadline reviews_given? reviews_given_in_current_stage? revision? from_participant(participant) from_participant_id(id) from_user(user) get_author_feedback_data(participant_id, timeline_list) get_due_date_data(assignment, timeline_list) get_peer_review_data(participant_id, timeline_list) get_submission_data(assignment_id, team_id, timeline_list) get_timeline_data(assignment, participant, team) teamed_students(user, ip_address = nil) started? topic_name

[edit]Overall tasks

Team

Carmen Bentley,Mentor

  • Tushar Kundra,tkundra
  • Ram Chavali,ramlohith
  • Ayushi Rungta,Rungta1001

Files modified in current project

A model and a rspec file were modified for this project namely:

  • student_task.rb
  • student_task_spec.rb

Running Tests

What we need to do is to set up the environment and complete the 'student_task.rb' and 'student_task_spec.rb' to increase the path coverage from only 43.0% with 43 lines covered and 57 lines missed to above 90%.

You can run RSpec tests by executing the command:


rspec spec/models/student_task_spec.rb

After that, you can see the detailed coverage information by opening this file in your Expertiza folder.


coverage/index.html

Problem Statement

The following tasks were accomplished in this project:

  • Complete the insufficient unit tests for student_task.rb.
  • Increase path coverage from only 31.91% with 30 lines covered to above 92.47% with 87 lines covered.
  • Cover edge cases.
  • High branch coverage to be achieved.

Running the Project Locally

The project could be run locally by cloning the Github repository Expertiza and then running the following commands sequentially.


bundle install
rake db:create:all
rake db:migrate
rails s