CSC/ECE 517 Fall 2015 E1590 Integration testing for Team creation: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "Intro == Assignment == === Description === This project aims at developing an email based anonymous session between author and a reviewer so that reviewers can ask questions to...")
 
No edit summary
 
(49 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Intro
== '''Purpose''' ==
This project is to perform integration testing for team creation. The testing needs to be done with the help of RSpec and Capybara. The UI procedures need to be tested are:
* Log in as a student
* Choose a available topic
* Invite one or more students as teammates
* Students who get the invition could accept or denial
* After accept the invitation, the team should form and all teammates should have same topic


== Assignment ==
== '''Testing Tools and Concepts''' ==


=== Description ===
=== RSpec ===
This project aims at developing an email based anonymous session between author and a reviewer so that reviewers can ask questions to the authors for any doubts related to the assignments during peer reviewing.
Rspec <ref>[https://en.wikipedia.org/wiki/RSpec RSpec Wiki Page]</ref> is a behavior-driven development (BDD) framework for the Ruby programming language, inspired by JBehave. It contains its own mocking framework that is fully integrated into the framework based upon JMock. The framework can be considered a domain-specific language (DSL) and resembles a natural language specification.In this project we will use expectation part of RSpec at most time.


=== Purpose ===
; RSpec-expectations<ref>[https://github.com/rspec/rspec-expectations RSpec expectations page]</ref>
During reviews, many times reviewers will be having questions about the submitted material and if it's a blocker there is no way that the reviewer can progress further with the review.  As a result, reviewers will end up submitting the empty or incomplete review.
: RSpec::Expectations lets you express expected outcomes on an object in an example


=== Scope ===
; RSpec-rails<ref>[https://github.com/rspec/rspec-rails RSpec rails page]</ref>
This project is limited to an email based conversation for asking questions and answers. The reviewers would ask questions related to assignment submission doubts to which authors can respond. All this would be taken care as email responses using a link provided in the email. This project does not cater to any live interactive session with spontaneous back-to-back questions and responses.
: RSpec-rails is a testing framework for Rails 3.x and 4.x..


Following tasks would be incorporated in the project:
=== Capybara ===
* Provide a ‘TextArea’ input field on review forms, where any reviewer can type in their questions.
Capybara is a library written in the Ruby programming language which makes it easy to simulate how a user interacts with application. Capybara can talk with many different drivers which execute tests through the same clean and simple interface.<ref>[http://www.gamesparks.com/blog/automated-testing-with-cucumber-and-capybara/ Capybara page]</ref>Capybara helps developer test web applications by simulating how a real user would interact with app.<ref>[https://github.com/jnicklas/capybara Capybara github page]</ref>
* Create a new button ‘Ask for Quick Help’ on the review forms.
* An email would be send to the author with the link where he can respond to the questions asked by the reviewers for their submitted work.
* Reviewers would be notified by an email when authors respond to the the questions.


== Design ==
* Using Capybara with Cucumber:


=== Discussion of Resolution ===
<code> cucumber-rails gem </code> comes with Capybara support built-in
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum


=== Mock-Ups ===
* Using Capybara with RSpec:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum


=== Design Patterns ===
Load RSpec 2.x support by adding the line: <code> require 'capybara/rspec' </code>.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum


=== Use Cases ===
* Using Capybara with Test::Unit:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum


=== Proposed Tests ===
When using Rails, add the following code in <code> test_helper.rb </code> file to make Capybara available in all test cases deriving from <code>ActionDispatch::IntegrationTest </code>.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum


<code> class ActionDispatch::IntegrationTest </code>
    <code> # Make the Capybara DSL available in all integration tests </code>
    <code> include Capybara::DSL </code>
<code> end </code>


== Implementation ==
=== Integration test ===
Integration testing<ref>[https://msdn.microsoft.com/en-us/library/aa292128(v=vs.71).aspx Integration test]</ref> is a logical extension of unit testing. In its simplest form, two units that have already been tested are combined into a component. A component, in this time, refers to an integrated aggregate of more than one unit. The idea is to test combinations of pieces and eventually expand the process to test your modules with those of other groups.
* '''Big Bang for Integration test '''


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
Big Bang<ref>[http://www.tutorialspoint.com/software_testing_dictionary/big_bang_testing.htm Big Bang]</ref> Integration Testing is an integration testing strategy wherein all units are linked at once, resulting in a complete system. When this type of testing strategy is adopted, it is difficult to isolate any errors found, because attention is not paid to verifying the interfaces across individual units.


== Suggestions for Future Improvements ==
* '''Two apporachs: Top down and Bottom up'''


* This can be extended to a live interactive author-reviewer anonymous chat session inside the Expertiza reviews window.
•The top-down approach to integration testing requires the highest-level modules be test and integrated first. This allows high-level logic and data flow to be tested early in the process and it tends to minimize the need for drivers. However, the need for stubs complicates test management and low-level utilities are tested relatively late in the development cycle. Another disadvantage of top-down integration testing is its poor support for early release of limited functionality.
* A purging script can be developed which will clear all the interaction records every semester.


==References==
•The bottom-up approach requires the lowest-level units be tested and integrated first. These units are frequently referred to as utility modules. By using this approach, utility modules are tested early in the development process and the need for stubs is minimized. The downside, however, is that the need for drivers complicates test management and high-level logic and data flow are tested late. Like the top-down approach, the bottom-up approach also provides poor support for early release of limited functionality.
{{reflist}}
 
== '''Testing Plan''' ==
Based on the project requirements, the testing can be divided into the following parts:
 
T1. Ensure a student is able to login to the system.
 
T2. Ensure a student is able to choose a topic from the assignment.
 
T3. Ensure a student is able to form a team by inviting other students enrolled in this course.
    S1. If the invitation is sent to a student who isn't enrolled in the class, it should not be allowed.
    S2. If the invitation is sent to a student who is enrolled in the class, it should be allowed.
T4. Ensure an invitee is able to accept or reject.
   
T5. Ensure all teammates have the same topic.
    S1. If a student accepts the invitation and the student have a topic before, the topic should be dropped.
    S2. If a student accepts the invitation and did not have the topic before, the student should have the same topic as other teammates who accepted the invitation.
 
== '''Modifying factories''' ==
Factory_girl<ref>[https://github.com/thoughtbot/factory_girl]</ref> is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
The file listed below is used for modifying factories for test.
* /expertiza/spec/factories/factories.rb
 
Using factory_girl to modify course data.
 
  factory :course ,class:Course do
    name "CSC 517 Fall 2009"
    instructor_id nil
    directory_path "csc517/f09"
    info "Object-Oriented Languages and Systems"
    private true
    institutions_id nil
end
 
Using factory_girl to modify assignment data.
 
  factory :assignment ,class:Assignment do
    name "final2"
    directory_path "try"
    submitter_count 0
    course
    instructor_id nil
    private false
    num_reviews 0
    num_review_of_reviews 0
    num_review_of_reviewers 0
    review_questionnaire_id nil
    review_of_review_questionnaire_id nil
    teammate_review_questionnaire_id nil
    reviews_visible_to_all false
    association  :wiki_type ,:factory => :wikitype
    num_reviewers 0
    spec_location "bfbfb"
    author_feedback_questionnaire_id nil
    max_team_size 3
    ...
  end
 
Using factory_girl to set due date.
 
  factory :due_date ,class:DueDate do
    due_at  "2015-12-30 23:30:12"
    association :deadline_type, :factory => :deadline_type,strategy: :build
    assignment { Assignment.first || association(:assignment)}  
    submission_allowed_id nil
    review_allowed_id  nil
    resubmission_allowed_id  nil
    rereview_allowed_id  nil
    review_of_review_allowed_id  nil
    round  1
    flag  false
    threshold  1
    delayed_job_id  nil
    deadline_name  nil
    description_url nil
    quiz_allowed_id nil
    teammate_review_allowed_id nil
  end
 
== '''Scenario''' ==
[[File:5190_diagram1.jpg]]
 
== '''Testing Scenario''' ==
Using Capybara to test expertize by simulating how a real user would do to form or join a team.
The file listed below is used for simulating uses` behavior.
* /expertiza/spec/features/team_creation_spec.rb
 
Simulating one student creates a team and send an invitation to another student, and the other one accept this.
 
  it 'one student should send invitation and the other student should accept' do
  student=User.find_by_name("student2064") 
  role=student.role
  ApplicationController.any_instance.stub(:current_user).and_return(student)
  ApplicationController.any_instance.stub(:current_role_name).and_return('Student')
  ApplicationController.any_instance.stub(:current_role).and_return(role)
  visit '/student_task/list'
  expect(page).to have_content('final2')
  click_link 'final2'
  expect(page).to have_content('Submit or Review work for final2')
  click_link 'Signup sheet'
  expect(page).to have_content('Signup sheet for final2 assignment')
  visit '/sign_up_sheet/sign_up?assignment_id=1&id=1'
  expect(page).to have_content('Your topic(s)')
  visit '/student_task/list'
  expect(page).to have_content('final2')
  click_link 'final2'
  click_link 'Your team'
  expect(page).to have_content('final2_Team1')
  fill_in 'user_name', with:'student2065'
  click_button 'Invite'
  expect(page).to have_content('student2065')
  student=User.find_by_name("student2065") 
  role=student.role
  ApplicationController.any_instance.stub(:current_user).and_return(student)
  ApplicationController.any_instance.stub(:current_role_name).and_return('Student')
  ApplicationController.any_instance.stub(:current_role).and_return(role)
  visit '/student_task/list'
  expect(page).to have_content('final2')
  click_link 'final2'
  click_link 'Your team'
  #expect(page).to have_content('student2064')
  visit '/invitation/accept?inv_id=1&student_id=1&team_id=0'
  expect(page).to have_content('Team Name: final2_Team1')
 
=References=
<references></references>

Latest revision as of 03:29, 5 December 2015

Purpose

This project is to perform integration testing for team creation. The testing needs to be done with the help of RSpec and Capybara. The UI procedures need to be tested are:

  • Log in as a student
  • Choose a available topic
  • Invite one or more students as teammates
  • Students who get the invition could accept or denial
  • After accept the invitation, the team should form and all teammates should have same topic

Testing Tools and Concepts

RSpec

Rspec <ref>RSpec Wiki Page</ref> is a behavior-driven development (BDD) framework for the Ruby programming language, inspired by JBehave. It contains its own mocking framework that is fully integrated into the framework based upon JMock. The framework can be considered a domain-specific language (DSL) and resembles a natural language specification.In this project we will use expectation part of RSpec at most time.

RSpec-expectations<ref>RSpec expectations page</ref>
RSpec::Expectations lets you express expected outcomes on an object in an example
RSpec-rails<ref>RSpec rails page</ref>
RSpec-rails is a testing framework for Rails 3.x and 4.x..

Capybara

Capybara is a library written in the Ruby programming language which makes it easy to simulate how a user interacts with application. Capybara can talk with many different drivers which execute tests through the same clean and simple interface.<ref>Capybara page</ref>Capybara helps developer test web applications by simulating how a real user would interact with app.<ref>Capybara github page</ref>

  • Using Capybara with Cucumber:

cucumber-rails gem comes with Capybara support built-in

  • Using Capybara with RSpec:

Load RSpec 2.x support by adding the line: require 'capybara/rspec' .

  • Using Capybara with Test::Unit:

When using Rails, add the following code in test_helper.rb file to make Capybara available in all test cases deriving from ActionDispatch::IntegrationTest .

 class ActionDispatch::IntegrationTest 
    # Make the Capybara DSL available in all integration tests 
    include Capybara::DSL 
 end 

Integration test

Integration testing<ref>Integration test</ref> is a logical extension of unit testing. In its simplest form, two units that have already been tested are combined into a component. A component, in this time, refers to an integrated aggregate of more than one unit. The idea is to test combinations of pieces and eventually expand the process to test your modules with those of other groups.

  • Big Bang for Integration test

Big Bang<ref>Big Bang</ref> Integration Testing is an integration testing strategy wherein all units are linked at once, resulting in a complete system. When this type of testing strategy is adopted, it is difficult to isolate any errors found, because attention is not paid to verifying the interfaces across individual units.

  • Two apporachs: Top down and Bottom up

•The top-down approach to integration testing requires the highest-level modules be test and integrated first. This allows high-level logic and data flow to be tested early in the process and it tends to minimize the need for drivers. However, the need for stubs complicates test management and low-level utilities are tested relatively late in the development cycle. Another disadvantage of top-down integration testing is its poor support for early release of limited functionality.

•The bottom-up approach requires the lowest-level units be tested and integrated first. These units are frequently referred to as utility modules. By using this approach, utility modules are tested early in the development process and the need for stubs is minimized. The downside, however, is that the need for drivers complicates test management and high-level logic and data flow are tested late. Like the top-down approach, the bottom-up approach also provides poor support for early release of limited functionality.

Testing Plan

Based on the project requirements, the testing can be divided into the following parts:

T1. Ensure a student is able to login to the system.

T2. Ensure a student is able to choose a topic from the assignment.

T3. Ensure a student is able to form a team by inviting other students enrolled in this course.

   S1. If the invitation is sent to a student who isn't enrolled in the class, it should not be allowed.
   S2. If the invitation is sent to a student who is enrolled in the class, it should be allowed.

T4. Ensure an invitee is able to accept or reject.

T5. Ensure all teammates have the same topic.

   S1. If a student accepts the invitation and the student have a topic before, the topic should be dropped.
   S2. If a student accepts the invitation and did not have the topic before, the student should have the same topic as other teammates who accepted the invitation.

Modifying factories

Factory_girl<ref>[1]</ref> is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance. The file listed below is used for modifying factories for test.

  • /expertiza/spec/factories/factories.rb

Using factory_girl to modify course data.

 factory :course ,class:Course do
   name "CSC 517 Fall 2009"
   instructor_id nil
   directory_path "csc517/f09"
   info "Object-Oriented Languages and Systems"
   private true
   institutions_id nil
end

Using factory_girl to modify assignment data.

 factory :assignment ,class:Assignment do
   name "final2"
   directory_path "try" 
   submitter_count 0 
   course
   instructor_id nil
   private false
   num_reviews 0
   num_review_of_reviews 0
   num_review_of_reviewers 0
   review_questionnaire_id nil
   review_of_review_questionnaire_id nil
   teammate_review_questionnaire_id nil
   reviews_visible_to_all false
   association  :wiki_type ,:factory => :wikitype
   num_reviewers 0
   spec_location "bfbfb"
   author_feedback_questionnaire_id nil
   max_team_size 3
   ...
 end

Using factory_girl to set due date.

 factory :due_date ,class:DueDate do
   due_at  "2015-12-30 23:30:12"
   association :deadline_type, :factory => :deadline_type,strategy: :build 
   assignment { Assignment.first || association(:assignment)}   
   submission_allowed_id nil
   review_allowed_id  nil
   resubmission_allowed_id  nil
   rereview_allowed_id  nil
   review_of_review_allowed_id  nil
   round  1
   flag  false
   threshold  1
   delayed_job_id  nil
   deadline_name  nil
   description_url nil
   quiz_allowed_id nil
   teammate_review_allowed_id nil
 end

Scenario

Testing Scenario

Using Capybara to test expertize by simulating how a real user would do to form or join a team. The file listed below is used for simulating uses` behavior.

  • /expertiza/spec/features/team_creation_spec.rb

Simulating one student creates a team and send an invitation to another student, and the other one accept this.

 it 'one student should send invitation and the other student should accept' do
 student=User.find_by_name("student2064")  
 role=student.role
 ApplicationController.any_instance.stub(:current_user).and_return(student)
 ApplicationController.any_instance.stub(:current_role_name).and_return('Student')
 ApplicationController.any_instance.stub(:current_role).and_return(role)
 visit '/student_task/list'
 expect(page).to have_content('final2')
 click_link 'final2'
 expect(page).to have_content('Submit or Review work for final2')
 click_link 'Signup sheet'
 expect(page).to have_content('Signup sheet for final2 assignment')
 visit '/sign_up_sheet/sign_up?assignment_id=1&id=1'
 expect(page).to have_content('Your topic(s)')
 visit '/student_task/list'
 expect(page).to have_content('final2')
 click_link 'final2'
 click_link 'Your team'
 expect(page).to have_content('final2_Team1')
 fill_in 'user_name', with:'student2065'
 click_button 'Invite'
 expect(page).to have_content('student2065') 
 student=User.find_by_name("student2065")  
 role=student.role
 ApplicationController.any_instance.stub(:current_user).and_return(student)
 ApplicationController.any_instance.stub(:current_role_name).and_return('Student')
 ApplicationController.any_instance.stub(:current_role).and_return(role)
 visit '/student_task/list'
 expect(page).to have_content('final2')
 click_link 'final2'
 click_link 'Your team'
 #expect(page).to have_content('student2064') 
 visit '/invitation/accept?inv_id=1&student_id=1&team_id=0'
 expect(page).to have_content('Team Name: final2_Team1')

References

<references></references>