alexgorbatchev

Friday, December 13, 2013

Jasmine Testing Framework - syntax comparison to Junit and Spock


Example Jasmine Test Suite

describe('This is my test suite', function () {
  var testObject;  

  beforeEach(function(){
    testObject = new TestObject();
  });

  it('This is my test', function(){
   expect(testObject.doSomething()).toEqual('Some Value');
  });

});
JasmineJUnitSpock
describeTestCaseSpecification
Describes a feature of an application and can be nested inside on another.

beforeEach@Before / setUp()setup()
Piece of code run before each test used to initialize testing objects.

it@Test<test function>()
Runs one test of the larger test suite.  Contains a test name and a function.

expect & (toEqual(), toBeTruthy(), etc)assert*()Any conditions in an expect: block
Conditions to check during the test.

afterEach@After / tearDown()cleanup()
Piece of code run after every test to tear down or destroy any testing objects.

No comments:

Post a Comment