CSC/ECE 517 Fall 2015/oss E1574 BKS: Difference between revisions

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


====rspec-rails====
====rspec-rails====
rspec-rails is a testing framework for Rails 3.x and 4.x. It supports testing of models, controllers, requests, features, views and routes. It does this by accepting test scenarios called specs.<ref>https://github.com/rspec/rspec-rails</ref>
Rspec-rails is a testing framework for Rails 3.x and 4.x. It supports testing of models, controllers, requests, features, views and routes. It does this by accepting test scenarios called specs.<ref>https://github.com/rspec/rspec-rails</ref>


====capybara====
====capybara====
Capybara helps you test web applications by simulating how a real user would interact with your app. It is agnostic about the driver running your tests and comes with Rack::Test and Selenium support built in. WebKit is supported through an external gem.<ref>https://github.com/jnicklas/capybara</ref>


 
===Test Scenarios===
===Feature test scenarios covered===
Based on the steps involved in manual submission of the assignment, the following test scenarios are considered:
Scenarios
# scenario 'student with valid credentials'
# scenario 'student with valid credentials'
# scenario 'no assignment available to submit'
# scenario 'submit only valid link to ongoing assignment'
# scenario 'submitting link for finished assignment'
# scenario 'submit only invalid link to ongoing assignment'
# scenario 'submitting file for finished assignment'
# scenario 'submit only existing file to ongoing assignment'
# scenario 'submitting link to ongoing assignment'
# scenario 'submit both valid link and file to ongoing assignment'
# scenario 'submitting file to ongoing assignment'
# scenario 'submit link for finished assignment'
# scenario 'submit file for finished assignment'


===Code written for feature test===  
===Code written for feature test===  
===assignment_creation.rb===
===assignment_creation.rb===
===student_assignment_submission.rb===
===student_assignment_submission.rb===

Revision as of 02:47, 1 November 2015

Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. <ref>Template:Expertiza GitHub Page</ref>

Introduction

Our contribution in this project is to write feature test for assignment submission by student. The test would mock steps taken by the student to manually submit the assignment.

Problem Statement

Once an assignment is created by the instructor the only call to action for the student is assignment submission. Currently, there is no feature test for assignment submission. The goal is to understand the flow of the assignment submission by student manually and mock this flow in the Feature Tests using RSpec and Capybara.

Feature Test

Feature specs test your application's functionality from the outside either by simulating a browser or by headless browser simulation.

Assumptions

To successfully implement each scenario in the test, the following assumptions are taken:

  1. The feature test will use the development environment. In particular, it will use the expertiza_development database.
  2. A student entry is assumed to be present in the database. The credentials for this student is student13 as username and password as password.
  3. The assignment created for testing contain no teams and topic selections.
  4. Users require to first run the ["assignment_creation.rb"], before they can run the tests.

Steps for manual submission

Before analyzing code, one must make themselves familiar with the steps involved in assignment submission by student on Expertiza. The steps involved are:

  1. Login with valid student username and password
  2. Click on an assignment to submit
  3. Click on "Your Work"
  4. Paste the link or browse to the file containing your work
  5. Click on "Upload Link" or "Upload File" to submit deliverable

Creating the Tests

Gems involved

The gems used in feature testing are rspec-rails and capybara

rspec-rails

Rspec-rails is a testing framework for Rails 3.x and 4.x. It supports testing of models, controllers, requests, features, views and routes. It does this by accepting test scenarios called specs.<ref>https://github.com/rspec/rspec-rails</ref>

capybara

Capybara helps you test web applications by simulating how a real user would interact with your app. It is agnostic about the driver running your tests and comes with Rack::Test and Selenium support built in. WebKit is supported through an external gem.<ref>https://github.com/jnicklas/capybara</ref>

Test Scenarios

Based on the steps involved in manual submission of the assignment, the following test scenarios are considered:

  1. scenario 'student with valid credentials'
  2. scenario 'submit only valid link to ongoing assignment'
  3. scenario 'submit only invalid link to ongoing assignment'
  4. scenario 'submit only existing file to ongoing assignment'
  5. scenario 'submit both valid link and file to ongoing assignment'
  6. scenario 'submit link for finished assignment'
  7. scenario 'submit file for finished assignment'

Code written for feature test

assignment_creation.rb

student_assignment_submission.rb

Other Changes

Running the tests

Steps

  1. Git fork
  2. bundle install
  3. db:migrate
  4. use command rspec spec/features/student_assignment_submission_spec.rb

Test Results=

Project Resources

GitHub Link Video Tutorial Images

References

External links