Testing

From Wiki2
Revision as of 10:59, 20 November 2015 by Tim (talk | contribs) (→‎testing)

testing

regression testing

Regression testing is a type of software testing that seeks to uncover new software bugs, or regressions, in existing functional and non-functional areas of a system after changes such as enhancements, patches or configuration changes, have been made to them. The purpose of regression testing is to ensure that changes such as those mentioned above have not introduced new faults. One of the main reasons for regression testing is to determine whether a change in one part of the software affects other parts of the software. Regression tests can be broadly categorized as functional tests or unit tests. Functional tests exercise the complete program with various inputs. Unit tests exercise individual functions, subroutines, or object methods

Contrast with non-regression testing (usually validation-test for a new issue), which aims to verify whether, after introducing or updating a given software application, the change has had the intended effect.

http://jsfiddle.net/fdietz/2Ny8x/

npm install mocha chai --save-dev

  same as
npm i -D mocha chai

create a test file src/index.test.js

 var expect = require('chai').expect;
 var starWars = require('./index');
 describe('starwars-names', function() {
   describe('all', function() {
     it('should be an array of strings', function() {
       expect(starWars.all).to.satisfy(isArrayOfStrings);
       function isArrayOfStrings(array) {
         return array.every(function(item) {
           return typeof item === 'string';
         });
       }
     });
     it('should contain `Luke Skywalker`', function() {
       expect(starWars.all).to.include('Luke Skywalker');
     });
   });
   describe('random', function() {
     it('should return a random item from the starWars.all', function() {
       var randomItem = starWars.random();
       expect(starWars.all).to.include(randomItem);
     });
   });
 });

change package.json to run tests (automatically on update -w)

 "scripts": {
   "test": "mocha src/index.test.js -w"
 },
 npm test