Personal understanding and practice of continuous integration

Source: Internet
Author: User
Tags grails

Currently, there are few teams and no Testers in the real sense. How can we ensure the code quality? I recently read the "continuous delivery-System Method for releasing reliable software", which was very inspired. I suddenly figured out the design concepts of many integrated development tools and made some practices, A special record is recorded and shared with everyone.

How to Ensure code Quality

I think continuous integration is essential to ensure that the version on the Code server is always runable. In terms of coarse granularity, functions are implemented in stages, and functions in each stage are completely available, which has many advantages, you can adjust the results as early as possible, discover bugs as early as possible, and boost morale if you have any results. In fine granularity, you can test what you submit each time and fix problems as early as possible.

How can we achieve this goal? The principle is to automate repetitive work and enable frequent testing. Specifically, it is automated testing, automated packaging, and automated deployment.

Automated Testing is designed to allow frequent and repeated tests to detect problems earlier. In order for developers to be diligent in testing, the testing run time must be short enough. Continuous integration advocates that a test is submitted and executed each time. Only unit tests are conducted to ensure the speed. This is why the unit is used separately in grails to encourage testing.

Automated packaging I do not use advanced tools, that is, using the packaging script written by ant + Ivy, and using Grails ideas, different packaging parameters can be used to pack dev, test, and prod, this greatly reduces the probability of manual packaging errors.

Automated deployment is now supported by the platform using sae. After the war package is uploaded directly, the deployment is automated. But the problem with sae is what you pass the local test, but that environment does not necessarily work, It is very embarrassing.

Test types and division of labor

There are many terms for the test type, and there are many ambiguities in the last use, especially the integration test has multiple meanings. I think the best way to understand is: functional testing unit testing, component testing, acceptance testing) and non-functional testing exploratory testing, performance testing, capacity testing ). Developers only do what can be automated. Testers do what can be automated.

In this case, unit testing only tests a certain class independently from the outside. In order to achieve this effect, there is still a lot of work. The class of external dependency should be simulated using Mock, and try not to connect to these external dependencies of the database. Component testing is to have these external dependencies, which can also be called functional testing. The acceptance test is to simulate user behavior and perform a series of operations. This is done at the final release to ensure the correctness of user usage.

However, note that each test must be independent from each other, otherwise it will greatly increase the maintenance difficulty.

What I expect

Unit testing is a good thing, but in fact I think component testing covers the unit function, but it only takes a little longer to run, but to reduce the workload of testing code, I want to skip unit testing and use all components for testing. A tricky problem in component testing is that databases are used, while databases are stateful. The sequence of testing operation affects the test results, so the best way is to roll back every test execution.

Acceptance testing is a new concept. It puts a user's operations on a function together for functional performance acceptance. Although there will be a large amount of maintenance, it can effectively simulate user behavior and perform a complete test of the function effect to achieve regression testing.

To sum up, the component test is used to achieve the results of frequent tests, and the acceptance test is used to achieve the regression test results.

Test Framework

In order to achieve the above results, I checked a circle of data and tried several frameworks. Junit4 is recognized as the simplest and most effective framework and has many extension plug-ins and IDE support, but its disadvantage is that its functions are too simple. To implement rollback after each test, you need to combine dbunit and integrate with spring. mock also has many tools to choose from.

Finally, we found an integrated testing framework Unitlis, which not only integrates the above requirements, but also simplifies configuration operations and implements version management of Database Upgrade files. After the trial, I felt very good and very loving. The official homepage is http://unitils.sourceforge.net/summary.html.

I think Unitils has the following significant advantages:

1. Reflection-based assertions are very powerful. They automatically filter out null and null values, and ignore the order of arrays. They are based on the comparison of the content itself.
2. spring management is integrated and declared using annotations, which is clear and concise.
3. The integration of dbunit simplifies many configurations, especially the transaction rollback configuration is flexible and simple.
4. the built-in Mock is very easy to use and the syntax is very beautiful, although it is not intended to be used for the moment.

 

References:
1. unitils cookbook: http://unitils.sourceforge.net/cookbook.html
2. Those things of development testing: http://stamen.iteye.com/blog/1466145
3. King of test integration Unitils: http://stamen.iteye.com/blog/1480316
4. Use unitils to test Service layer: http://stamen.iteye.com/blog/1485837
5. Continuous delivery-system methods for releasing reliable software

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.