Mustafa Güven
Mustafa Güven

Reputation: 15744

Using Emma without Junit through Jenkins + ANT + Android

I need to prepare a reporting system which will be displayed the code parts are used and not used by the application and in this particular case I'm going to use EMMA. However there will be no any test code next to project and emma will scan only the methods and give such a report like "20% are not using, %80 are in use" etc...

  1. Is this possible?
  2. If yes how should I configure ant without junit? (Please share sample ant code)
  3. Do I need to make something additional to work with jenkins?

Upvotes: 2

Views: 401

Answers (1)

Andrei T
Andrei T

Reputation: 3083

I will try to provide an answer after all even though you didn't tell what exactly you have and need.
Step 1. The first thing to do is to configure Hudson. First step I did was to download hudson war file and run it.
Step 2. What I did here was to start it via java command line and configure the plugins that I need. In your case the plugins are svn, git and android emulator. See below how to configure Hudson.
Configure Hudson Link 1
Configure Hudson Link 2
Next, I downloaded tomcat and I configured the web.xml file from webapps/hudson/web-inf to link to the hudson home just created earlier.
Now, once you managed to run hudson properly, you can start configuring hudson and next the jobs.
Step 3. Configuring Hudson. You start by configuring Hudson, by setting up the plugins you need, like Apache Ant, Android Emulator, etc.
Step 4. Configuring jobs. You have two type of jobs: normal and test. See below a printscreen for the required configuration.
Hudson General Configuration Common things for both jobs is the repository URL of your online URL, SVN, Git, etc. A printscreen for a normal job can be seen at: Hudson normal Job For the test job on the other hand you have to configure a bit more. You start by configuring the build environment. If you installed the Android Emulator plugin you should see options " Run an Android emulator during build". This has to be checked together with some other information. A small tutorial can be found here. I would say it is pretty similar.
Android on Hudson.
Once you achieved this, further on you configure ant. Here, you check the Ant version to be one that you set before in the general settings section and, as for the targets, I used the following option: "clean-set-absolute-tested-path emma instrument nodeps verbose-output-file-for-emma install test fetch-test-report".
Now, in order to see the coverage reports, I used a plugin that allows you to publish the coverage reports as an HTML page and this option can be found at the post-build actions step. For a better understanding see the image:
Hudson Test project job part 1
Hudson Test project job part 2
Step 5. Configuring the xml files. Now, once hudson is done, further on you start configuring the project in eclipse. You start by creating a test project for your app(I hope you know how to do that) and after that you create the files ant.properties, build.xml and project.properties. At first, you create the build xml and the ant properties files for the library. An example of a build xml for the library can be found at:
http://pastebin.com/WiD2Y6j4
Also, the ant.properties for the library can be found at:
http://pastebin.com/cpuGVDhL
Further on, you need the configuration for the test app. Build xml:
http://pastebin.com/yjC8TViT
Ant properties:
http://pastebin.com/5STqMV6b
Once you have committed your code and run the jobs you created before, you should be able to see the html report for your code, classes %, methods % and even what your logic tested. However, from my experience the latter(logic testing) has not proven to be quite an exact science. Hope it helps. That's pretty much the configuration we use at my work. So far was successful.

Upvotes: 1

Related Questions