CSC/ECE 517 Fall 2017/E1766 Test team functionality: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Background ==
== Background ==
Expertiza is an open source web based peer review system developed and maintained by students and faculty at North Carolina State University. It enables students enrolled in a particular course to form online teams and complete assignments. A typical cycle of an assignment involves the following major steps:
Expertiza is a peer review based system which provides incremental learning from the class. This project has been developed together by faculty and students using Ruby on Rails framework. Expertiza allows the instructor to create, edit and delete assignments, create new assignment topics, assign them to a particular class or selected students, have students work on teams and then review each other's assignments at the end. For the students, they can signup for topics, form teams, and submit their projects and assignments. Students then review the work done by other students and give suggestions to improve. Teams after reviews are allotted scores and they can refer to the peer comments to further improve their work. It also supports submission of different file types for assignments, including the URLs and wiki pages.
 
* A pool of topics is made available to the students to choose from and form team to complete it within a pre-set deadline.
* After the development phase is finished, begins the peer review phase. Here students can review work of other teams, on the basis of some predefined factors and provide their feedback.
* Members of a team can also provide feedback for the respective review done for their work.
* In some projects there is a second development phase which allows team members to improve upon their work keeping past reviews in consideration.
* After this second development cycle begins another review phase, where original reviewers can re-review the updated work and provide critical feedback.  


== Purpose ==
== Purpose ==
Line 20: Line 14:
Capybara gem allows a user to test their web application through simulations.
Capybara gem allows a user to test their web application through simulations.


== Functional Tests Implementation ==
== Test Plan (Implementation of functional tests) ==


=== Functional Tests for Create group assignment ===
=== Functional Tests for Create group assignment ===
Line 73: Line 67:
<pre>
<pre>
it "should impersonate as student" do
it "should impersonate as student" do
     user = User.find_by(name: "student2064")
     user = User.find_by(name: "student2064")
     stub_current_user(user, user.role.name, user.role)
     stub_current_user(user, user.role.name, user.role)
Line 86: Line 79:
     assignment_id = Assignment.first.id
     assignment_id = Assignment.first.id
     visit "/sign_up_sheet/sign_up?id=#{assignment_id}&topic_id=1"
     visit "/sign_up_sheet/sign_up?id=#{assignment_id}&topic_id=1"
     expect(page).to have_content('Your topic(s): test_topic_1')
     expect(page).to have_content('Your topic(s): test_topic_1')  
 
   end
   end
</pre>
</pre>
Line 106: Line 98:
=== Functional Tests for accepting an invitation ===
=== Functional Tests for accepting an invitation ===


In Expertiza assignments, the only way for a student to join an existing team is to be invited by the leader. Therefore, we will test whether the invitation function run smoothly. But before the test, we need to initialize some information.  
In Expertiza assignments, the only way for a student to join an existing team is to be invited by the leader.


<pre>
Following test spec has been written to accept the invitation to join the team and verify that the assignment topic is assigned to all users
before(:each) do
    create(:assignment, name: "TestTeam", directory_path: 'test_team')
    create_list(:participant, 3)
    create(:assignment_node)
    create(:deadline_type, name: "submission")
    create(:deadline_type, name: "review")
    create(:deadline_type, name: "metareview")
    create(:deadline_type, name: "drop_topic")
    create(:deadline_type, name: "signup")
    create(:deadline_type, name: "team_formation")
    create(:deadline_right)
    create(:deadline_right, name: 'Late')
    create(:deadline_right, name: 'OK')
    create(:assignment_due_date, deadline_type: DeadlineType.where(name: 'review').first, due_at: Time.now + (100 * 24 * 60 * 60))
    #create(:topic)
    create(:topic, topic_name: "work1")
    end
</pre>
 
Here, we created a team, and set the maximum students to 3. Because there can only be one student in each session of browser, we need to create different sessions for different students. The first session is for the leader who will be the first one who select this topic.


<pre>
<pre>
  it "case1" do
it "joins the team" do
    in_browser(:one) do
     user = User.find_by(name: "student2065")
    #test log in as a student
     stub_current_user(user, user.role.name, user.role)
     user = User.find_by_name('student2064')
     visit '/student_task/list'
     msg = user.to_yaml
    expect(page).to have_content('public assignment for test')
     File.open('log/diagnostic.txt', 'a') {|f| f.write msg }
     visit '/invitation/accept?inv_id=1&student_id=1&team_id=1'
     visit root_path
     visit '/student_teams/view?student_id=1'
    fill_in 'login_name', with: 'student2064'
     expect(page).to have_content('Team Information for public assignment for test')
     fill_in 'login_password', with: 'password'
     click_button 'SIGN IN'


     expect(page).to have_content "User: student2064"
     # to test invalid case - student who is not part of the team does not have created assignment
     expect(page).to have_content "TestTeam"
     user = User.find_by(name: "student2066")
 
     stub_current_user(user, user.role.name, user.role)
    click_link "TestTeam"
     visit '/student_task/list'
    expect(page).to have_content "Signup sheet"
     page.should has_no_content?('public assignment for test')
    expect(page).to have_content "Your team"
 
     #test if the topic can be seen and chosen by a student
    click_link "Signup sheet"
    expect(page).to have_content "work1"
    my_link = find(:xpath, "//a[contains(@href,'sign_up_sheet/sign_up?assignment_id=#{Assignment.last.id}&id=1')]")
    my_link.click
 
    #test after selecting a topic, a team formed
    click_link "Assignments"
    click_link "TestTeam"
    expect(page).to have_content "Your team"
    click_link "Your team"
    expect(page).to have_content "Team Name"
     expect(page).to have_content "student2064"
 
    #test if a team leader can invite another student
     page.fill_in 'user_name', :with => 'student2065'
    click_button('Invite')
    expect(page).to have_content "Sent invitations"
    expect(page).to have_content "student2065"
   end
   end
</pre>
</pre>
So far,  a team has been created by ‘student2064’, who is the leader. Then, we will let him send an invitation to another user  ‘student2065’. Now, let’s create a new session which allows ’student2065’ to log in. After the login, we need to test if he receive the invitation and if he accepts it, whether or not he will be in the team. If he is included in the team, he will be able to see the name of the leader, who is ‘student2064’.
<pre>
in_browser(:two) do
    visit '/'
    user = User.find_by_name('student2065')
    msg = user.to_yaml
    File.open('log/diagnostic.txt', 'a') {|f| f.write msg }
    visit root_path
    fill_in 'login_name', with: 'student2065'
    fill_in 'login_password', with: 'password'
    click_button 'SIGN IN'
    #test if a student can see an invitation
    expect(page).to have_content "User: student2065"
    expect(page).to have_content "TestTeam"
    click_link "TestTeam"
    expect(page).to have_content "Signup sheet"
    expect(page).to have_content "Your team"
    click_link "Assignments"
    click_link "TestTeam"
    expect(page).to have_content "Your team"
    click_link "Your team"
    expect(page).to have_content "Received Invitations"
    expect(page).to have_content "student2064"
    #test if a student can accept an invitation
    click_link "Accept"
    expect(page).to have_content "Team Information"
    expect(page).to have_content "Team members"
    expect(page).to have_content "Edit name "
    expect(page).to have_content "student2064"
    expect(page).to have_content "student2065"
    expect(page).to have_content "Leave team"
end
</pre>
===Functional Tests for rejecting an invitation===
Same as the previous one, we set up the information at the beginning, and then let ‘student2064’ to pick up a topic and send an invitation to ‘student2065’. This time, we will let ‘student2065’ to choose to reject this invitation. If he declines the invitation, the invitation will disappear.
<pre>
#test if a student can decline an invitation
      click_link "Decline"
      expect(page).to have_no_content "Received Invitations"
</pre>
===Functional Tests for sending an invitation by a team member===
Same as the first case, we let ‘student2064’ to pick up a topic and send an invitation to ‘student2065’. Then, ‘student2065’ accepts the invitation and becomes a team member. Now we test if ‘student2065’ can send an invitation to another student—‘student2066’.
<pre>
      #invite another student
      page.fill_in 'user_name', :with => 'student2066'
      click_button('Invite')
      expect(page).to have_content "Sent invitations"
      expect(page).to have_content "student2066"
</pre>
Now, let’s create the third session and login as ‘student2066’. If the invitation sent by ‘student2065’ is successful, ‘student2066’ should be able to see an ‘Received Invitation’ by ‘student2065’ in ‘Your Team’ page.
<pre>
    in_browser(:three) do
      visit '/'
      #login as student2065
      user = User.find_by_name('student2066')
      msg = user.to_yaml
      File.open('log/diagnostic.txt', 'a') {|f| f.write msg }
      visit root_path
      fill_in 'login_name', with: 'student2066'
      fill_in 'login_password', with: 'password'
      click_button 'SIGN IN'
      #test if a student can see an invitation
      expect(page).to have_content "User: student2066"
      expect(page).to have_content "TestTeam"
      click_link "TestTeam"
      expect(page).to have_content "Signup sheet"
      expect(page).to have_content "Your team"
      click_link "Assignments"
      click_link "TestTeam"
      expect(page).to have_content "Your team"
      click_link "Your team"
      expect(page).to have_content "Received Invitations"
      expect(page).to have_content "student2065"
      #test if a student can accept an invitation
      click_link "Accept"
      expect(page).to have_content "Team Information"
      expect(page).to have_content "Team members"
      expect(page).to have_content "Edit name "
      expect(page).to have_content "student2064"
      expect(page).to have_content "student2065"
      expect(page).to have_content "student2066"
      expect(page).to have_content "Leave team"
    end
</pre>
===Functional Tests for leaving a team by a team member===
Everything is same to the first case except the last two lines of codes. In the last two lines, we let ‘student2065’ to leave the team, if he really leaves, he will see “You no longer have a team” in the next page.
<pre>
    click_link "Leave team"
    expect(page).to have_content "You no longer have a team! "
</pre>
===Functional Tests for leaving a team by a team leader===
Everything is same to the first case before we change back to session one. If ‘student2064’ (Team leader) clicks “Leave team”, he should see  “You no longer have a team” in the next page.
<pre>
    in_browser(:one) do
      click_link "Assignments"
      click_link "TestTeam"
      expect(page).to have_content "Your team"
      click_link "Your team"
      expect(page).to have_content "student2064"
      expect(page).to have_content "student2065"
      click_link "Leave team"
      expect(page).to have_content "You no longer have a team! "
    end
</pre>


===Functional Tests for whether students choosing the same topic are in the same team===
===Functional Tests for whether students choosing the same topic are in the same team===
Line 315: Line 140:


== Result ==
== Result ==
[[File:new1.PNG|200px|Image: 200 pixels]]


[[File:new2.PNG|200px|Image: 200 pixels]]
Coverage increased (+0.3%) to 51.108% when pulling 4915488 on ankit13jain:master into 781e456 on expertiza:master.


== External Links ==
== External Links ==

Latest revision as of 21:35, 28 October 2017

Background

Expertiza is a peer review based system which provides incremental learning from the class. This project has been developed together by faculty and students using Ruby on Rails framework. Expertiza allows the instructor to create, edit and delete assignments, create new assignment topics, assign them to a particular class or selected students, have students work on teams and then review each other's assignments at the end. For the students, they can signup for topics, form teams, and submit their projects and assignments. Students then review the work done by other students and give suggestions to improve. Teams after reviews are allotted scores and they can refer to the peer comments to further improve their work. It also supports submission of different file types for assignments, including the URLs and wiki pages.

Purpose

The purpose of this task is to write functional tests for team functionality. Once an assignment is out, a student can select this assignment and others can join in the team. To test this functionality we wrote functional tests for the various scenarios. One such scenario is :

  • Once the assignment is out and a student selects it, he/she can send out invites to other students to join the team.
  • Invited students can accept the invitation and join the team.

Functional Tests

Functional tests ensure that the functionalities of a software system are working as expected. To write our functional tests, we used the Capybara gem available for Ruby. Capybara gem allows a user to test their web application through simulations.

Test Plan (Implementation of functional tests)

Functional Tests for Create group assignment

In Expertiza instructor can create public assignment for particular course, define the required rubrics and add students to that assignment.

The following test spec has been written to create public group assignment

def create_new_assignment
  login_as("instructor6")
  visit "/assignments/new?private=0"

  fill_in 'assignment_form_assignment_name', with: 'public assignment for test'
  select('Course 2', from: 'assignment_form_assignment_course_id')
  fill_in 'assignment_form_assignment_directory_path', with: 'testDirectory'
  fill_in 'assignment_form_assignment_spec_location', with: 'testLocation'
  check("assignment_form_assignment_microtask")
  check("team_assignment")
  fill_in 'assignment_form_assignment_max_team_size', with: '3', visible: false
  check("assignment_form_assignment_reviews_visible_to_all")
  check("assignment_form_assignment_is_calibrated")
  check("assignment_form_assignment_availability_flag")
  expect(page).to have_select("assignment_form[assignment][reputation_algorithm]", options: ['--', 'Hamer', 'Lauw'])

  click_button 'Create'
end

Add topics to the assignment

def add_topic_to_assignment assignment
  visit "/assignments/#{assignment.id}/edit"
  click_link 'Topics'
  click_link 'New topic'
  fill_in 'topic_topic_identifier', with: '112'
  fill_in 'topic_topic_name', with: 'test_topic_1'
  fill_in 'topic_category', with: 'test_topic_1'
  fill_in 'topic_max_choosers', with: 3
  click_button 'Create'
  create(:assignment_due_date)
  create_list(:participant, 3)
end

Functional Tests for Log in as student and selecting a topic of assignment

When student login into his Expertiza account, he can check for new assignment under "Assignments" tab and choose the topic of his interest. Student then can send invitation to other students who are also enrolled in same course. We have written following test spec to impersonate as a student and select a topic

it "should impersonate as student" do
    user = User.find_by(name: "student2064")
    stub_current_user(user, user.role.name, user.role)
    visit '/student_task/list'
    # Assignment name
    expect(page).to have_content('public assignment for test')
    click_link 'public assignment for test'
    expect(page).to have_content('Submit or Review work for public assignment for test')

    click_link 'Signup sheet'
    expect(page).to have_content('Signup sheet for public assignment for test assignment')
    assignment_id = Assignment.first.id
    visit "/sign_up_sheet/sign_up?id=#{assignment_id}&topic_id=1"
    expect(page).to have_content('Your topic(s): test_topic_1') 
  end

Sending invitations to other students

    visit '/student_task/list'
    click_link 'public assignment for test'
    click_link 'Your team'
    expect(page).to have_content('public assignment for test_Team1')
    fill_in 'user_name', with: 'student2065'
    click_button 'Invite'
    fill_in 'user_name', with: 'student2066'
    click_button 'Invite'
    expect(page).to have_content('student2065')

Functional Tests for accepting an invitation

In Expertiza assignments, the only way for a student to join an existing team is to be invited by the leader.

Following test spec has been written to accept the invitation to join the team and verify that the assignment topic is assigned to all users

it "joins the team" do
    user = User.find_by(name: "student2065")
    stub_current_user(user, user.role.name, user.role)
    visit '/student_task/list'
    expect(page).to have_content('public assignment for test')
    visit '/invitation/accept?inv_id=1&student_id=1&team_id=1'
    visit '/student_teams/view?student_id=1'
    expect(page).to have_content('Team Information for public assignment for test')

    # to test invalid case - student who is not part of the team does not have created assignment
    user = User.find_by(name: "student2066")
    stub_current_user(user, user.role.name, user.role)
    visit '/student_task/list'
    page.should has_no_content?('public assignment for test')
  end

Functional Tests for whether students choosing the same topic are in the same team

Since the only way for students to be in a team is by invitation, students who choose the same topic will be in different team. Our test is to let two different students select the same topic and see if their teammates contains each other. Therefore, first we let ‘student2064’ and 'student2065' sign for the same topic, and in their pages, to see if there is 'student2065' or 'student2064'.

      expect(page).to have_content "Team Name"
      expect(page).to have_content "student2065"
      expect(page).to have_content "student2064"

Running the tests

The tests can be run on the terminal by navigating to the /spec/features directory using the command:

 rspec team_functionalities_spec.rb

Whether the test fails or succeeds, allows us to determine which parts of the system are functioning properly.

Result

Coverage increased (+0.3%) to 51.108% when pulling 4915488 on ankit13jain:master into 781e456 on expertiza:master.

External Links

  1. link for forked repository [[1]]
  2. Github link for original repository [[2]]
  3. Github link for Capybara [[3]]