CSC/ECE 517 Fall 2016 E1684: Feature Test for Assignment Submission

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

Expertiza

Expertiza is an open-source project on GitHub used by students to view/submit assignments and review others' work. Expertiza also provides tools to visualize the scores and gauge the improvements made during the course semester. It also facilitates and monitors team projects. It is targeted at educational and non-profit organizations.

Travis CI

Travis CI is a hosted, distributed continuous integration service used to build and test software projects hosted at GitHub.

Configuration: Travis CI is configured by adding a file named .travis.yml, which is a YAML format text file, to the root directory of the repository. This file specifies the programming language used, the desired building and testing environment (including dependencies which must be installed before the software can be built and tested), and various other parameters.

Operation: When Travis CI has been activated for a given repository, GitHub will notify it whenever new commits are pushed to that repository or a pull request is submitted. It can also be configured to only run for specific branches, or branches whose names match a specific pattern. Travis CI will then check out the relevant branch and run the commands specified in .travis.yml, which usually build the software and run any automated tests. When that process has completed, Travis notifies the developer(s) in the way it has been configured to do so—for example, by sending an email containing the test results (showing success or failure), or by posting a message on an IRC channel. In the case of pull requests, the pull request will be annotated with the outcome and a link to the build log, using a GitHub integration.

Capybara

Capybara supports selenium-webdriver, which is mostly used in web-based automation frameworks. It supports JavaScript, can access HTTP resources outside the application, and can also be setup for testing in headless mode which is especially useful for CI scenarios.

Using Capybara with RSpec: Load RSpec 2.x support by adding the following line(typically to the spec_helper.rb file):

require 'capybara/rspec' 

Project Requirement

There should be a feature test for submission of the assignment by the student. Once the assignment is created by the instructor the only call to action for the student is assignment submission. The purpose of this project is to test whether the submission function could work properly under different scenarios. We will design multiple test cases to simulate different scenarios which the system could encounter. For example, how system respond when a user uploads an invalid URL. The following part will provide more and detailed information on test cases.

Test Plan

When a user is attempting to submit an assignment, there are some possible cases need to be considered.

1. Upload single valid link: upload a valid link, the system should properly render the page and add this link into the database. We will use the following statements to simulate the submit action.

    fill_in 'submission', with: "https://www.google.com"
    click_on 'Upload link'

2. Upload invalid link: upload an invalid link (e.g. a non-existing link), the system should detect the invalid link, reject the submission and cast corresponding error message.

3. Upload multiple links: upload multiple links, the system should properly render the page and add the new link into the database. We will use the following statement to check if the current page has the uploaded URL.

    expect(page).to have_content "https://www.google.com"

4. Upload duplicated links: upload an link which has already been uploaded before, the system should detect this duplicated link, reject the submission and cast error message.

5. Upload empty link: upload an empty link, the system should reject the submission and cast corresponding error message.

6. Upload a valid file: upload a valid file, the system should properly render the page and add this file into the directory. We will use the following statements to simulation the submit action.

    attach_file('uploaded_file', file_path)
    click_on 'Upload file'

7. Upload multiple files: upload multiple files, the system should properly render the page and add the new file into the directory.

8. Upload duplicated files: upload a file which has already been uploaded before, the system should update the existed file with new one. The test code will check whether the content of this specific file was successfully updated.

Approach

1. First, using factories to create test data: create assignment, create topic, create participant.

before(:each) do
      create(:assignment, name: "Assignment1684", directory_path: "Assignment1684")
      create_list(:participant, 3)
      create(:topic, topic_name: "Topic")
      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: "submission").first, due_at: DateTime.now + 1)
  end

2. Mock the workflow of Assignment submission using Capybara.

3. Check the result of the submission from both web page and database.

In database level, the submission results are stored in the table: TEAMS.