Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 34

Domains Apps

Continuous Integration and Tools

NUR ZUR INTERNEN VERWENDUNG

Overview

2 1&1 Internet AG 2011

NUR ZUR INTERNEN VERWENDUNG

Continuous Integration
Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily leading to multiple integrations per day. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. Agile teams, because they are producing robust code each iteration, typically find that they are slowed down by the long diff-resolution and debugging sessions that often occur at the end of long integration cycles. Continuous Integration (CI) involves producing a clean build of the system several times per day. Agile teams typically configure CI to include automated compilation, unit test execution Code stays robust enough that customers and other stakeholders can play with the code whenever they like - It also encourages more feedback between programmers and customers, which helps the team get things right before iteration deadlines
1&1 Internet AG 2011

NUR ZUR INTERNEN VERWENDUNG

Page3

CI Principles
Maintain a code repository Automate the build Make the build self-testing Every commit (to baseline) should be built Test in a clone of the production environment Everyone can see the results of the latest build Automate deployment

Everyone commits to the baseline every day

1&1 Internet AG 2011

NUR ZUR INTERNEN VERWENDUNG

Page4

Assumption is the mother of all screw-ups


o Developers can revert the codebase to a bug-free state without wasting time debugging

Developers detect and fix integration problems continuously avoiding last-minute chaos at release dates

o o

Early warning of broken/incompatible code / conflicting changes Immediate unit testing of all changes

Constant availability of a "current" build for testing, demo, or


release purposes

Frequent code check-in pushes developers to create modular, less complex code

Metrics generated from automated testing and CI focus


developers on developing functional, quality code

1&1 Internet AG 2011

NUR ZUR INTERNEN VERWENDUNG

Page5

What's the cost?

Seldom do the users of the software say to me, "Wow, I really like the way you integrated the software in the last release."
o Initial setup time required
o Well-developed test-suite required to achieve automated testing advantages

1&1 Internet AG 2011

NUR ZUR INTERNEN VERWENDUNG

Page6

Setup and minimizing the effort

NUR ZUR INTERNEN VERWENDUNG

Hudson / Jenkins
Building/testing software projects continuously Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs, even those that

are run on a remote machine.

NUR ZUR INTERNEN VERWENDUNG

Hudson / Jenkins
Easy to install Lots of configuration options Easy integration of plugins 600 and counting plugins, and you can write your own(s) Cascading and concurrent builds, join option Rest API for Python, XML and JSON Chuck Norris plugin!

NUR ZUR INTERNEN VERWENDUNG

Ant
Ant is a Java library and command-line tool and can be used to pilot any type of process which can be described in terms of targets and tasks Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Create your own tasks or download opensouce antlibs

NUR ZUR INTERNEN VERWENDUNG

Ant and JSMin


JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. The JSMin Ant task acts as an interface to the JSMin Java class. The task can be used for the automated minification of javascript files in your build and deploy processes.
Define the task in your build file:

Using the task on a single file, with the .min suffix added to the file extension:

Using the task with a fileset, and an output directory specified:

NUR ZUR INTERNEN VERWENDUNG

Maven
At first glance Maven can appear to be many things, but in a nutshell Maven is an attempt to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices.
In fact: Maven is a build tool. In many ways it is like the well-known tool ANT, only even more powerful. (it's more like Ant on steroids. ) It is designed to take much of the hard work out of the build process

NUR ZUR INTERNEN VERWENDUNG

Maven mvn archetype:generate -DgroupId=blahblah DartifactId=SpringExamples -DarchetypeArtifactId=maven-archetypequickstart Optional mvn eclipse:eclipse In pom.xml:

Then mvn <goal/lifecycle>

NUR ZUR INTERNEN VERWENDUNG

Maven

+ clean and site lifecycles plugins in charge with goals

NUR ZUR INTERNEN VERWENDUNG

Maven

NUR ZUR INTERNEN VERWENDUNG

Maven + JS ?
As soon as you stop thinking of your JavaScript code as a bastard step-child, you can apply the same practices that we have in our other worlds (e.g. Java).

This means that maven will try to grab from the configured repositories: /[groupId]/[type]s/[artifactId]-[version].[type] or in the example above: /myGroup/jss/oneOfMyScripts.js maven-war-javascript plugin The maven-war-javascript-plugin offers a war:js / war:js:copy-scripts goal. This manually looks through your dependencies, and copies any JavaScript modules to your web app. If you also need to package the webapp as war, the plugin registers itself with the war module, and whenever it is invoked, it sneaks in and does the copy. More info : http://ajaxian.com/archives/using-maven-to-modularize-javascript-development

NUR ZUR INTERNEN VERWENDUNG

Cobertura
Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. Cobertura was initially designed to be run from Ant. First, you had to add a task definition to the build.xml file.

Next, you need a cobertura-instrument task that adds the logging code to the already compiled class files.

Finally, the cobertura-report task generates the HTML output

NUR ZUR INTERNEN VERWENDUNG

Cobertura

NUR ZUR INTERNEN VERWENDUNG

Cobertura

Other similar tools: Emma, Clover JSCoverage is a tool that measures code coverage for JavaScript programs.
NUR ZUR INTERNEN VERWENDUNG

Sonar Sonar is an open platform to manage code quality. Sonar has a rich set of features like what you would get with different tools such as Covertura, PMD, FindBugs, Check Styles combined. It covers the 7 axes of code quality:

NUR ZUR INTERNEN VERWENDUNG

Sonar

One part of Sonar is a Web front-end for the metrics database, and the other part is a

Maven plugin that runs all code analyzers and pumps the collected data into that
database. Easy to install - much like Hudson / Jenkins Download Modify db connection properties (comes with Derby DB included) Run .bat / .sh mvn clean install sonar:sonar in the project root

Browse to http://localhost:9000

NUR ZUR INTERNEN VERWENDUNG

Sonar

NUR ZUR INTERNEN VERWENDUNG

What about the tests?

TDD Fitnesse Selenium Mockito

NUR ZUR INTERNEN VERWENDUNG

What is TDD ?

NUR ZUR INTERNEN VERWENDUNG

TDD theory and practice


You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. You are not allowed to write any more production code than is sufficient to pass the one failing unit test. If it's worth building, it's worth testing. If it's not worth testing, why are you wasting your time working on it?

NUR ZUR INTERNEN VERWENDUNG

Fitnesse

FitNesse is a test framework that allows testers, developers and customers to collaborate

to create test cases on a wiki. Teams can take examples of desired software behavior and
turn them into automated tests, integrated with narrative requirements documentation. FitNesse runs its own wiki web server Testing within the FitNesse system involves four components per test: The wiki page which expresses the test as a decision table. A testing engine, which interprets the wiki page. A test fixture, which is invoked by the testing engine and in turn invokes the

system under test.


The system under test, which is being tested.

NUR ZUR INTERNEN VERWENDUNG

Fitnesse

NUR ZUR INTERNEN VERWENDUNG

Fitnesse
Fixture

NUR ZUR INTERNEN VERWENDUNG

Fitnesse

NUR ZUR INTERNEN VERWENDUNG

Selenium
Selenium is a portable software testing framework for Web applications. Selenium IDE - Plugin to Firefox to record and play test in firefox and also export tests in different languages. Selenium RC- Allows playing of exported test in different platform/OS Selenium Grid - Allows to control lots of selenium machines not for now

NUR ZUR INTERNEN VERWENDUNG

Selenium RC
Client libraries which provide the interface between each programming language and the Selenium RC Server. To create a test program, you simply write a program that runs a set of Selenium commands using a client library API. Well, there are a lot of libraries and plugins offering various functionalities and different syntax

NUR ZUR INTERNEN VERWENDUNG

Selenium + Fitnesse = ...


And what if we write a test Fitnesse-style

and with some plugins, it gets transformed into code using Selenium?

We get Selenese. And this is not a joke


NUR ZUR INTERNEN VERWENDUNG

Mockito

NUR ZUR INTERNEN VERWENDUNG

Questions

How much of these concepts and tools do you use every day?

Which do you think the gain would be if most/all of them were used?

Your questions

Thank you!

NUR ZUR INTERNEN VERWENDUNG

You might also like