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

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "== 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...")
 
Line 238: Line 238:


== External Links ==
== External Links ==
# link for forked repository [[https://github.com/hli36/expertiza.git]]  
# link for forked repository [[https://github.com/ankit13jain/expertiza]]  
# Github link for original repository [[https://github.com/expertiza/expertiza.git]]
# Github link for original repository [[https://github.com/expertiza/expertiza.git]]
# Github link for Capybara [[https://github.com/jnicklas/capybara.git]]
# Github link for Capybara [[https://github.com/jnicklas/capybara.git]]

Revision as of 20:54, 26 October 2017

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:

  • 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

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.

Functional Tests Implementation

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.

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

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.

  it "case1" do
    in_browser(:one) do
    #test log in as a student
    user = User.find_by_name('student2064')
    msg = user.to_yaml
    File.open('log/diagnostic.txt', 'a') {|f| f.write msg }
    visit root_path
    fill_in 'login_name', with: 'student2064'
    fill_in 'login_password', with: 'password'
    click_button 'SIGN IN'

    expect(page).to have_content "User: student2064"
    expect(page).to have_content "TestTeam"

    click_link "TestTeam"
    expect(page).to have_content "Signup sheet"
    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

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’.

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


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.

 #test if a student can decline an invitation
      click_link "Decline"
      expect(page).to have_no_content "Received Invitations"

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’.

      #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"

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.

    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

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.

    click_link "Leave team"
    expect(page).to have_content "You no longer have a team! "


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.

    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


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 using the command:

 rspec team_functionality_spec.rb

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

Result

Image: 200 pixels

Image: 200 pixels

External Links

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