As you know we posted quite a few sample projects to show off the power of View and Data API, and we also keep polishing them to make them better. I am investigating the automatic testing of our sample project, in this post, I will share what I learned with the continuous integration tool - Travis-CI.
Firstly, I need to signup the Travis-CI service, since my source code is hosted on github, and Travic-CI allows us to login with github.com account. Once I logged in with github.com account, it asks me for authentication which orgranizations I authorize Travis-CI to access.
Now I have logged in Travis-CI, and my repository on github.com are listed. Just click the checkbox ahead of my repo to enable integration with Travis-CI.
Next step, I need to add
.travis.yml file into the root folder of project, and push it to github. The most important part in the content is the language, it tells Travis CI which language environment to select for your project. For my sample repo, it is a node.js repository, and as a start, I would like to test on different node.js versions:
Now push the changes with
git push to github repository, it will trigger the building and testing process. If everything is OK, I will get a green button, saying that my build is passed. And you can also see the build result:
Now continuous integration has been set up, pretty easy. Whenever a new push to github, the building and testing will be executed automatically by Travis-CI. To nortify users, I put a status icon to the readme of reposity, just editing readme.md of my repository as bellow:
Here is how it looks:
But as you wonder, what kind of testing did Travis-CI do? Actually nothing so far. I did not put any test code to my repo yet. Currently Travis-CI only check the
npm install on different node.js versions. When it goes to
npm test, no test case is found.
So next step is to create some test cases to verify whether the repository works or not, a lot stuffs to learn :)