SHIP YOUR CODE

delivery code quickly, relaxedly, safely

TEST

  • unit test
  • interface test( api test )
  • feature test
  • manual test

API TEST

  • 100% cover
  • run quickly
  • business-oriented

Unit Test

  • >= 80% cover
  • run quickly
  • logic-oriented
  • mock

Feature Test

  • core feature cover
  • browser
  • scenario-oriented

CI

  • deployment automation
  • > 95% test suites pass
  • manual test

Our System Technologies

CodeIgnitor( API TEST )



    $this->load->library('unit_test');
    $test = 1 + 1;
    
    $expected_result = 2;
    
    $test_name = 'Adds one plus one';
    
    $this->unit->run($test, $expected_result, $test_name);

Ionic Controller( Jasmine & Karma )



    beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
      $httpBackend = _$httpBackend_;
      $httpBackend.expectGET('phones/phones.json').
          respond([{name: 'Nexus S'}, {name: 'Motorola DROID'}]);

      scope = $rootScope.$new();
      ctrl = $controller('PhoneListCtrl', {$scope: scope});
    }));


    it('should create "phones" model with 2 phones fetched from xhr', function() {
      expect(scope.phones).toEqualData([]);
      $httpBackend.flush();

      expect(scope.phones).toEqualData(
          [{name: 'Nexus S'}, {name: 'Motorola DROID'}]);
    });
git clone --depth=14 https://github.com/angular/angular-phonecat.git

Feature Test( Protractor )



    beforeEach(function() {
      browser.get('app/index.html#/phones');
    });


    it('should filter the phone list as a user types into the search box', function() {

      var phoneList = element.all(by.repeater('phone in phones'));
      var query = element(by.model('query'));

      expect(phoneList.count()).toBe(20);

      query.sendKeys('nexus');
      expect(phoneList.count()).toBe(1);

      query.clear();
      query.sendKeys('motorola');
      expect(phoneList.count()).toBe(8);
    });
https://github.com/angular/protractor

CI System

  • Jenkins( recommend )
  • codeship( need money )
  • travisci( need money )

Deployment Automation

  • magephp
  • phing

Pyramid in Test

Continous Integration Flow

Who Follows This Flow?

  • Google
  • Mozilla
  • Mircosoft
  • Apple
  • Most of OpenSource Projects( CodeIgniter too )

Thanks & QA

I'm WinDy

Post at March 12, 2015

ship your code

By Li Yafei

ship your code

  • 2,810