CSC/ECE 517 Spring 2013/OSS E600: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(66 intermediate revisions by 2 users not shown)
Line 2: Line 2:


'''Writing Assignment 2'''
'''Writing Assignment 2'''
Work in progress. Due 3/20/2013
__TOC__
__TOC__


== Introduction ==
== Introduction ==
There were three goals in the OSS E600 project <ref name='assignment'> http://courses.ncsu.edu/csc517/common/homework/OSS/expertiza.html</ref>
There were three goals in the OSS E600 project <ref name='assignment'> http://courses.ncsu.edu/csc517/common/homework/OSS/expertiza.html</ref>
#Restructure the feature files for better organization.  Feature folders like 'student' had few scenarios strung out between many files.  Reconsolidate the files to make them more useful.
#Restructure the feature files for better organization.  Feature folders like 'student' had few scenarios strung out between many files.  Consolidate the files to make them more useful.
#Determine a gem that will generate code coverage reports.  It needs to work with Ruby 1.8.7 and Rails 2.
#Determine a gem that will generate code coverage reports.  It needs to work with Ruby 1.8.7 and Rails 2.
#Use the coverage tool to find areas that need the most improvement.  Then create new tests targeting those areas to increase coverage.
#Use the coverage tool to find areas that need the most improvement.  Then create new tests targeting those areas to increase coverage.


== Setup ==
== Setup ==
Setting up the coverage + cucumber environment is very similar to setting up for only cucumber.  The majority of the instructions in the old cucumber [http://wiki.expertiza.ncsu.edu/index.php?title=Using_Cucumber_with_Expertiza wiki] still apply.<ref name='old_wiki'>http://wiki.expertiza.ncsu.edu/index.php?title=Using_Cucumber_with_Expertiza</ref>  
Setting up the coverage + [http://en.wikipedia.org/wiki/Cucumber_(software) cucumber] environment is very similar to setting up for only cucumber.  The majority of the instructions in the old cucumber [http://wiki.expertiza.ncsu.edu/index.php?title=Using_Cucumber_with_Expertiza wiki] still apply.<ref name='old_wiki'>http://wiki.expertiza.ncsu.edu/index.php?title=Using_Cucumber_with_Expertiza</ref>
 
The gem we choose is called [https://github.com/relevance/rcov rcov], and we have the one by [https://github.com/relevance/rcov relevance]. <ref name='rcov_gem'>http://rubygems.org/gems/rcov</ref>


Follow the [http://wikis.lib.ncsu.edu/index.php/Creating_a_Linux_Development_Environment_for_the_Expertiza_Application linux wiki] to setup Expertiza.  Assuming that [https://github.com/expertiza/expertiza Expertiza] is already running, enter these commands:
Follow the [http://wikis.lib.ncsu.edu/index.php/Creating_a_Linux_Development_Environment_for_the_Expertiza_Application linux wiki] to setup Expertiza.  Assuming that [https://github.com/expertiza/expertiza Expertiza] is already running, enter these commands:
Line 29: Line 28:
       t.fork = true # You may get faster startup if you set this to false
       t.fork = true # You may get faster startup if you set this to false
       t.profile = 'default'
       t.profile = 'default'
       t.rocv = true #add this line for coverage report
       t.rcov = true #add this line for coverage report
     end
     end


Line 36: Line 35:
       t.fork = true # You may get faster startup if you set this to false
       t.fork = true # You may get faster startup if you set this to false
       t.profile = 'wip'
       t.profile = 'wip'
       t.rocv = true #add this line for coverage report
       t.rcov = true #add this line for coverage report
     end
     end


Line 43: Line 42:
       t.fork = true # You may get faster startup if you set this to false
       t.fork = true # You may get faster startup if you set this to false
       t.profile = 'rerun'
       t.profile = 'rerun'
       t.rocv = true #add this line for coverage report
       t.rcov = true #add this line for coverage report
     end
     end
</pre>
</pre>
Line 53: Line 52:
rake features
rake features
</pre>
</pre>
When cucumber runs you should see green/yellow/red text as each scenario runs and either passes, skips or fails.
<br />
'''Cucumber Example'''
<br />
[[File:Cucumber_ex.png]]


===Run All Features <ref name='old_wiki'/>===
===Run All Features <ref name='old_wiki'/>===
Line 70: Line 74:
The reports will be in an HTML format.  View the report by opening ./coverage/index.html in a [http://en.wikipedia.org/wiki/Web_browser browser].
The reports will be in an HTML format.  View the report by opening ./coverage/index.html in a [http://en.wikipedia.org/wiki/Web_browser browser].


*<put screenshot of directory here with index.html selected>
The main output of [https://github.com/relevance/rcov rcov]is a web page shown below which lists each source file on the left followed by the coverage percentage of that source file.  Clicking on the source file link will show the line by line coverage of that source file.  
*<put screenshot of output here>
 
[[Image:Cuke-features.png|right]] test
[[File:coverage_screen.jpg]]


== Design Patterns ==
== Design Patterns ==
Line 79: Line 83:
The Cucumber system, however, does exhibit the [http://en.wikipedia.org/wiki/Facade_pattern? Facade Pattern].  The Facade Pattern provides a simplified interface to a software system.  The Cucumber package provides this facade through the steps in Capybara.  The simplified interface allows the software developer to write tests in something close to a natural language.
The Cucumber system, however, does exhibit the [http://en.wikipedia.org/wiki/Facade_pattern? Facade Pattern].  The Facade Pattern provides a simplified interface to a software system.  The Cucumber package provides this facade through the steps in Capybara.  The simplified interface allows the software developer to write tests in something close to a natural language.


== Conclusion ==
== Outcome ==
 
=== File Organization ===
Before there were 35 feature files.  They have been consolidated to 20 files.  The largest improvement is the feature folder 'student' as shown below:
 
{| class="wikitable"
! style="width: 50%" | Before
! style="width: 50%" | After
|-
|[[File:Before.PNG|left|Before]]
|[[File:After.PNG|227px|After]]
|}
 
=== Coverage Increase ===
The overall coverage increase was small, but measurable. 12 new scenarios were created to achieve the increase.
<br/>
Before
*Total Coverage: 33.29%
*Code coverage: 26.70%
<br />
After
*Total Coverage: 34.17%
*Code coverage: 27.45%


== Demonstration Video ==
A demonstration video walks through the project.  Click [https://www.youtube.com/watch?v=r29BdG-EV4A Here] to view.


== References ==
== References ==
<references/>
<references/>

Latest revision as of 03:26, 21 March 2013

OSS E600

Writing Assignment 2

Introduction

There were three goals in the OSS E600 project <ref name='assignment'> http://courses.ncsu.edu/csc517/common/homework/OSS/expertiza.html</ref>

  1. Restructure the feature files for better organization. Feature folders like 'student' had few scenarios strung out between many files. Consolidate the files to make them more useful.
  2. Determine a gem that will generate code coverage reports. It needs to work with Ruby 1.8.7 and Rails 2.
  3. Use the coverage tool to find areas that need the most improvement. Then create new tests targeting those areas to increase coverage.

Setup

Setting up the coverage + cucumber environment is very similar to setting up for only cucumber. The majority of the instructions in the old cucumber wiki still apply.<ref name='old_wiki'>http://wiki.expertiza.ncsu.edu/index.php?title=Using_Cucumber_with_Expertiza</ref>

The gem we choose is called rcov, and we have the one by relevance. <ref name='rcov_gem'>http://rubygems.org/gems/rcov</ref>

Follow the linux wiki to setup Expertiza. Assuming that Expertiza is already running, enter these commands:

gem install relevance-rcov
bundle install
rake db:create
rake db:test:prepare

Modify the file ./lib/task/cucumber.rake. Add the line "t.rcov=true" below each of the three t.profile lines.

    Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
      t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
      t.fork = true # You may get faster startup if you set this to false
      t.profile = 'default'
      t.rcov = true #add this line for coverage report
    end

    Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
      t.binary = vendored_cucumber_bin
      t.fork = true # You may get faster startup if you set this to false
      t.profile = 'wip'
      t.rcov = true #add this line for coverage report
    end

    Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
      t.binary = vendored_cucumber_bin
      t.fork = true # You may get faster startup if you set this to false
      t.profile = 'rerun'
      t.rcov = true #add this line for coverage report
    end

Running

Run Coverage and All Features

Enter the command below to run the entire cucumber feature suite and get code coverage reports.

rake features

When cucumber runs you should see green/yellow/red text as each scenario runs and either passes, skips or fails.
Cucumber Example

Run All Features <ref name='old_wiki'/>

To run all cucumber features found within the ./features directory:

bundle exec cucumber

Run a Single Feature <ref name='old_wiki'/>

To run all scenarios for a single cucumber feature:

bundle exec cucumber features/admin/impersonate_user.feature

Run a Single Scenario <ref name='old_wiki'/>

To run specific scenario within a feature, specify the line number:

bundle exec cucumber features/admin/impersonate_user.feature:5

Coverage Reports

The coverage reports will be generated in the folder ./coverage. <ref name='rcov'> https://github.com/cucumber/cucumber/wiki/Using-RCov-with-Cucumber-and-Rails </ref> The reports will be in an HTML format. View the report by opening ./coverage/index.html in a browser.

The main output of rcovis a web page shown below which lists each source file on the left followed by the coverage percentage of that source file. Clicking on the source file link will show the line by line coverage of that source file.


Design Patterns

The work that we did in implementing this project did not introduce any new design patterns to the Expertiza system that were of our own creation.

The Cucumber system, however, does exhibit the Facade Pattern. The Facade Pattern provides a simplified interface to a software system. The Cucumber package provides this facade through the steps in Capybara. The simplified interface allows the software developer to write tests in something close to a natural language.

Outcome

File Organization

Before there were 35 feature files. They have been consolidated to 20 files. The largest improvement is the feature folder 'student' as shown below:

Before After
Before
Before
After

Coverage Increase

The overall coverage increase was small, but measurable. 12 new scenarios were created to achieve the increase.
Before

  • Total Coverage: 33.29%
  • Code coverage: 26.70%


After

  • Total Coverage: 34.17%
  • Code coverage: 27.45%

Demonstration Video

A demonstration video walks through the project. Click Here to view.

References

<references/>