E1853 Menu Model Testing: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
CSC-517 Fall 2018 - E1853 Testing the Menu Model in Expertiza Project | CSC-517 Fall 2018 - E1853 Testing the Menu Model in Expertiza Project. | ||
This Wiki page explains how tests were performed for the Menu Model of the Expertiza project. | This Wiki page explains how tests were performed for the Menu Model of the Expertiza project. | ||
Line 5: | Line 5: | ||
===Expertiza=== | ===Expertiza=== | ||
[http://expertiza.ncsu.edu/ Expertiza] is an Open Source project based on the [http://rubyonrails.org/ Ruby on Rails] framework, supported by National Science Foundation. It is the software to create reusable learning objects through peer review. It is a project where students can submit and peer review learning objects(articles, code, websites, etc). The users of this software include students and professors. Expertiza is used by select professors and students in North Carolina State University, for example. It supports team projects, reviews of projects/teammates, submission URLs, Wiki pages and certain document types. Instructors can create projects and the students can bid for the projects. The students can be assigned teams for a particular project or they may form their own team with fellow classmates. | [http://expertiza.ncsu.edu/ Expertiza] is an Open Source project based on the [http://rubyonrails.org/ Ruby on Rails] framework, supported by National Science Foundation. It is the software to create reusable learning objects through peer review. It is a project where students can submit and peer review learning objects(articles, code, websites, etc). The users of this software include students and professors. Expertiza is used by select professors and students in North Carolina State University, for example. It supports team projects, reviews of projects/teammates, submission URLs, Wiki pages and certain document types. Instructors can create projects and the students can bid for the projects. The students can be assigned teams for a particular project or they may form their own team with fellow classmates. | ||
===Test Driven Development=== | |||
[http://en.wikipedia.org/wiki/Test-driven_development/ Test Driven Development] is a software development process that relies on the repetition of a very short development cycle, requirements are turned into very specific [http://en.wikipedia.org/wiki/Test_case/ test cases], then the software is improved to pass the new test cases only. This is opposed to software development that allows software to be added that is not proven to meet requirements. | |||
Test-driven development is related to the test-first programming concepts of extreme programming, begun in 1999,but more recently has created more general interest in its own right. | |||
The TDD sequence can be can be summarized in following steps: | |||
# Add a Test | |||
# Run all tests and see if the new test fails | |||
# Write the code | |||
# Run tests | |||
# Refactor code | |||
# Repeat | |||
Advantages of using TDD: | |||
*Narrowing Problem Focus | |||
*Tidier Code | |||
*Not worrying about dependencies | |||
*Easier refactoring | |||
*Better Test coverage and fewer bugs | |||
===Unit Testing=== | |||
[http://en.wikipedia.org/wiki/Unit_testing Unit Testing] is a software testing method by which individual units of source code are tested to catch errors early in the development process. For a model it involves testing the interface and on how it responds to commands and queries from outside. Model testing is bounded to the functionality of only the model under test and doesn't test how its collaborating models get affected based on this query. | |||
Unit Testing provides several benefits which can be summarized in the below points. | |||
1. Finds problems early: | |||
Unit testing finds problems early in the development cycle. This includes both bugs in the programmer's implementation and flaws or missing parts of the specification for the unit. | |||
In test-driven development (TDD), which is frequently used in both extreme programming and scrum, unit tests are created before the code itself is written. When the tests pass, that code is considered complete. | |||
2. Facilitates change: | |||
Unit testing allows the programmer to refactor code or upgrade system libraries at a later date, and make sure the module still works correctly (e.g., in regression testing). The procedure is to write test cases for all functions and methods so that whenever a change causes a fault, it can be quickly identified. Unit tests detect changes which may break a design contract. | |||
3. Simplifies Integration: | |||
Unit testing may reduce uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier. | |||
4. Documentation: | |||
Developers looking to learn what functionality is provided by a unit, and how to use it, can look at the unit tests to gain a basic understanding of the unit's interface's API. | |||
5. Design: | |||
When software is developed using a test-driven approach, the combination of writing the unit test to specify the interface plus the refactoring activities performed after the test is passing, may take the place of formal design. Each unit test can be seen as a design element specifying classes, methods, and observable behavior. | |||
==Problem Statement== | |||
The goal of the project is to test the Menu.rb, i.e. the Menu model by writing unit tests, which are written using [http://rspec.info/ Rspec]. The unit tests are to be written such that the path coverage of menu.rb is greater than 90% and achieve the highest possible branch coverage. | |||
===Files Involved=== | |||
The following files were involved: | |||
# app/models/menu.rb (already existing) | |||
# spec/models/menu_spec.rb(created as part of this project) | |||
===Team Members=== | |||
The members involved in the project include : | |||
# Ameya Dhavalikar(student) | |||
# Hasham Mukhtar(student) | |||
# Mingkang Zhuang | |||
# Zhewei Hu(mentor) | |||
==Plan of Work== | |||
==Implementation== | |||
===Expertiza environment setup=== | |||
===Functionality of Menu model=== | |||
===Test entries creation=== | |||
===Edge case testing=== | |||
==Tests== | |||
==Conclusion and Learning Outcomes== | |||
After writing the test cases we used SimpleCov to measure the C0 coverage of our rails application. SimpleCov was already installed earlier. | |||
After running rake spec to run the test cases, SimpleCov creates a directory called coverage in our rails application folder. | |||
This folder called coverage contains an index.html file which when opened in a browser renders an html page which gives the C0 coverage of each of the files in the Controllers, Models, Helpers in the app directory. | |||
These are the learning outcomes after performing this project: | |||
1. Writing tests using the Test Driven Development approach. | |||
2. Writing unit tests for models and controllers in RSpec. | |||
3. Understanding the functionality of an already developed application. In our case, before writing the test cases for the menu.rb we had the understand how different models interacted with each other and how each action by different users would make changes in the database schema. | |||
4. An understanding of how different tables are structures in the schema in large applications. | |||
==References== | |||
#[http://expertiza.ncsu.edu/ The live Expertiza website] | |||
#[http://github.com/expertiza/expertiza Expertiza on GitHub] | |||
#[http://github.com/AmeyaDhavalikar/expertiza Forked Repository from GitHub] | |||
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki] |
Revision as of 06:57, 2 November 2018
CSC-517 Fall 2018 - E1853 Testing the Menu Model in Expertiza Project. This Wiki page explains how tests were performed for the Menu Model of the Expertiza project.
Introduction
Expertiza
Expertiza is an Open Source project based on the Ruby on Rails framework, supported by National Science Foundation. It is the software to create reusable learning objects through peer review. It is a project where students can submit and peer review learning objects(articles, code, websites, etc). The users of this software include students and professors. Expertiza is used by select professors and students in North Carolina State University, for example. It supports team projects, reviews of projects/teammates, submission URLs, Wiki pages and certain document types. Instructors can create projects and the students can bid for the projects. The students can be assigned teams for a particular project or they may form their own team with fellow classmates.
Test Driven Development
Test Driven Development is a software development process that relies on the repetition of a very short development cycle, requirements are turned into very specific test cases, then the software is improved to pass the new test cases only. This is opposed to software development that allows software to be added that is not proven to meet requirements. Test-driven development is related to the test-first programming concepts of extreme programming, begun in 1999,but more recently has created more general interest in its own right.
The TDD sequence can be can be summarized in following steps:
- Add a Test
- Run all tests and see if the new test fails
- Write the code
- Run tests
- Refactor code
- Repeat
Advantages of using TDD:
- Narrowing Problem Focus
- Tidier Code
- Not worrying about dependencies
- Easier refactoring
- Better Test coverage and fewer bugs
Unit Testing
Unit Testing is a software testing method by which individual units of source code are tested to catch errors early in the development process. For a model it involves testing the interface and on how it responds to commands and queries from outside. Model testing is bounded to the functionality of only the model under test and doesn't test how its collaborating models get affected based on this query.
Unit Testing provides several benefits which can be summarized in the below points.
1. Finds problems early: Unit testing finds problems early in the development cycle. This includes both bugs in the programmer's implementation and flaws or missing parts of the specification for the unit. In test-driven development (TDD), which is frequently used in both extreme programming and scrum, unit tests are created before the code itself is written. When the tests pass, that code is considered complete.
2. Facilitates change: Unit testing allows the programmer to refactor code or upgrade system libraries at a later date, and make sure the module still works correctly (e.g., in regression testing). The procedure is to write test cases for all functions and methods so that whenever a change causes a fault, it can be quickly identified. Unit tests detect changes which may break a design contract.
3. Simplifies Integration: Unit testing may reduce uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier.
4. Documentation: Developers looking to learn what functionality is provided by a unit, and how to use it, can look at the unit tests to gain a basic understanding of the unit's interface's API.
5. Design: When software is developed using a test-driven approach, the combination of writing the unit test to specify the interface plus the refactoring activities performed after the test is passing, may take the place of formal design. Each unit test can be seen as a design element specifying classes, methods, and observable behavior.
Problem Statement
The goal of the project is to test the Menu.rb, i.e. the Menu model by writing unit tests, which are written using Rspec. The unit tests are to be written such that the path coverage of menu.rb is greater than 90% and achieve the highest possible branch coverage.
Files Involved
The following files were involved:
- app/models/menu.rb (already existing)
- spec/models/menu_spec.rb(created as part of this project)
Team Members
The members involved in the project include :
- Ameya Dhavalikar(student)
- Hasham Mukhtar(student)
- Mingkang Zhuang
- Zhewei Hu(mentor)
Plan of Work
Implementation
Expertiza environment setup
Functionality of Menu model
Test entries creation
Edge case testing
Tests
Conclusion and Learning Outcomes
After writing the test cases we used SimpleCov to measure the C0 coverage of our rails application. SimpleCov was already installed earlier. After running rake spec to run the test cases, SimpleCov creates a directory called coverage in our rails application folder. This folder called coverage contains an index.html file which when opened in a browser renders an html page which gives the C0 coverage of each of the files in the Controllers, Models, Helpers in the app directory.
These are the learning outcomes after performing this project: 1. Writing tests using the Test Driven Development approach. 2. Writing unit tests for models and controllers in RSpec. 3. Understanding the functionality of an already developed application. In our case, before writing the test cases for the menu.rb we had the understand how different models interacted with each other and how each action by different users would make changes in the database schema. 4. An understanding of how different tables are structures in the schema in large applications.