ci : the first_step: auto testing with circleci - (mosg)

Post on 22-Jan-2018

445 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Continuous Integration - The first step of Auto Testing-

2016/07/07 Mulodo Vietnam Co., Ltd.

Continuous IntegrationIn software engineering, continuous integration (CI) is the practice of merging all developer working copies to a shared mainline several times a day.

Grady Booch first named and proposed CI in his 1991 method,[1] although he did not advocate integrating several times a day.

Extreme programming (XP) adopted the concept of CI and did advocate integrating more than once per day - perhaps as many as tens of times per day.

wikipedia

Almost development works are

‘Enhancement of current system’.

Why CI?

* Rapid cycle : ‘Plan(Enlarge) - Dev - Measure(Enlarge)’

* Tests : not only for new code, but also ALL. (to avoid regression)

Almost development works are

‘Enhancement of current system’.

Why CI?

* Rapid cycle : ‘Plan(Enlarge) - Dev - Measure(Enlarge)’

* Tests : not only for new code, but also ALL. (to avoid regression)

Tests are increasing || Dev cycle is going faster

Almost development works are

‘Enhancement of current system’.

Why CI?

* Rapid cycle : ‘Plan(Enlarge) - Dev - Measure(Enlarge)’

* Tests : not only for new code, but also ALL. (to avoid regression)

Tests are increasing || Dev cycle is going faster

No way out

dev cycle (engineer side)

https://www.apicasystem.com/blog/top-5-tips-avoid-integration-hell-continuous-integration/

PLAN CODE BUILD TEST RELEASE DEPLOY

legacy Engineering

dev cycle (engineer side)

PLAN CODE BUILD TEST RELEASE DEPLOY

Continuous Integration

Continuous Delivery

legacy Engineering

dev cycle (engineer side)

PLAN CODE BUILD TEST RELEASE DEPLOY

Continuous Integration

Continuous Delivery

legacy Engineering

dev cycle (engineer side)

Use Technology to solve the problem.

Auto-Testing

Auto-Deploy

dev cycle (from client side)

Huh? Tests? That’s not my business.

Please ask testers.

No problem. We are testing our code in

standard dev-flow

dev cycle (from client side)

Huh? Tests? That’s not my business.

Please ask testers.

No problem. We are testing our code in

standard dev-flow

Which engineer do you think better?

Aut0-Testing (auto-deploy)

So, “Testing” become a much important thing than you think.

Let’s start Auto-testing

Tools

CI tools

Test tools

https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks

Tools

CI tools

Test tools

https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks

Today’s GOAL

1. push code to github 2. (AUTO) Testing on Circle CI 3. (AUTO) E-mail reporting

very simple

Flow

That’s ALL

create repository on github.com

create sample code and unit test code

register to CircleCI

Flow

create repository on github.com

create sample code and unit test code

register to CircleCI

That’s ALL

You can try auto-testing very easy !

sample codegit@github.com:nemo-mulodo-vn/test_circleci.git

calc.php-------------------sampleclassphpunit.xml-----------------phpunitsettingtests/bootstrap.php----------phpunittestrunnnertests/calcTest.php----------phpunittestcode

composer.json--------------composersetting

sample code

$ git clone git@github.com:nemo-mulodo-vn/test_circleci.git Cloning into 'test_circleci'... remote: Counting objects: 20, done. remote: Compressing objects: 100% (14/14), done. remote: Total 20 (delta 1), reused 17 (delta 1), pack-reused 0 Receiving objects: 100% (20/20), done. Resolving deltas: 100% (1/1), done. Checking connectivity... done. $ cd test_circleci $ composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating autoload files $

preparation - git clone - install required modules w/ composer

sample code

$ ./vendor/bin/phpunit PHPUnit 4.8.26 by Sebastian Bergmann and contributors.

Runtime: PHP 5.5.30 Configuration: /Users/nemo/git/tmp/test_circleci/phpunit.xml

......

Time: 189 ms, Memory: 4.00MB

OK (6 tests, 6 assertions) $

test at local environment

register repository to CircleCI

1. Open CircleCI

https://circleci.com/

Note) Please open github.com with your account on another tab.

register repository to CircleCI

2. Request authorization to your github

register repository to CircleCI

3. Confirm authorization

register repository to CircleCI

4. Select account (or Organization)

register repository to CircleCI

5. Select repository

register repository to CircleCI

6. Start build and testing !!!!

environment

closing

testing

register repository to CircleCI

6. Start build and testing !!!!

environment

closing

testing<-donoting

This screenshot is on a case without any test code.

NO TEST

That’s ALL

Much easier than I thought

circle.ymlA configuration file for CircleCI

try to specify PHP version on CircleCI.

machine: php: version: 5.6.14

circle.yml

git add, commit, push

circle.ymlSome more example

machine: php: version: 5.6.14

dependencies: override: - composer install --prefer-source --no-interaction --dev

test: override: - echo “Thanks for spending your time"

circle.yml

https://circleci.com/docs/configuration/

You can deploy code to specified EC2 server and test on the server. (if u need)

Thank you

I am happy, If you become

motivated to test.

top related