Open source: xcov

Project :    https://code.google.com/p/xcov/

Short introduce:   enhance lcov-to-cobertura-xml to support converting gcov to coberuta and working with svn diff

Open source project lcov-to-cobertura-xml provide converting the lcov data to cobertura xml so that it can be easier integrated with Jenkins.

Thus, we have to handle the gcov data at first instead of lcov sometimes, What’s more, we only want to generate code coverage with svn code diff. So this tool enhance the lcov-to-cobertura-xml to support convert gcov data or work with svn diff file base on keeping the old features available.

Basic Usage:

Converts LCOV coverage data to Coberturacompatible XML for reporting. By default, XML output will be written to ./coverage.xml

xcov.py lcovfile.info
xcov.py lcov-file-1.info lcov-file-2.info
xcov.py lcov-file.info -s svndiffFilePath
xcov.py lcovfile.info -a srcPath:gcdaPath
xcov.py -a srcPath:gcdaPath
xcov.py lcovfile.info b src/dir e test.lib o path/out.xml

Options:

-h, –help show this help message and exit -b BASE_DIR, –base-dir=BASE_DIR

Directory where source files are located

-e EXCLUDES, –excludes=EXCLUDES

Comma-separated list of regexes of packages to exclude

-a SRCDSTPAIRS, –srcdstPairs=SRCDSTPAIRS

add src:dst path, the src path is source code path, the dst path is gcda/gcno path

-o OUTPUT, –output=OUTPUT

Path to store cobertura xml file

-w, –web

create html report

-d, –delete

delete the copied gcov data

-s, –svndiff

Path to store svn diff file path

By default

(1) gcdaPath=gcnoPath=objsPath

(2) XML output will be written to ./coverage.xml

(3) svndiffFilePath can be generated by svn diff command with option –summarize such as: svn diff -r {2014-05-01}:{2014-05-10} src/ –summarize > svndifffile.txt

Open source: common-remote-pool

Apache common object pool can help user to manager resource, but if use it , you will find you can only share resources in one machine,not between multi-process or multi-machine. So we use the object pool to constructor one web service to provide distributed pool to share resources between multiple machines. The web common remote pool provide one default implement which can add any json string to pool and borrow json resource from it.What’s more, the resource object factory’s class can be uploaded into the web service. In short, the project is restful style web object pool for global access.

http://code.google.com/p/common-remote-pool/

How to initial it

1. mvn tomcat7:run to start the webservice;

2. If you need define your implement, you should upload your resource factory class , if you have no need, omit this step.

How to use it

http request style

  • borrow the object from pool
 	Request:
 	        GET http://localhost:8080/common-remote-pool/service/object/borrow

 

Response: has resource response code:200 response body: json example: {“domain”:”10.224.64.225″,”user”:”6731″}

Response: no resource response code:404

 

  • return resource to pool
 	Request:
 		POST http://localhost:8080/common-remote-pool/service/object/return                 
                body: json
 		example:{"domain":"10.224.64.225","user":"6731"}

 

Response: response code:204

  • get borrowed resouce number
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/active

 

Response: response code:200 response body: number

  • add resource to pool
 	Request:
 		POST http://localhost:8080/common-remote-pool/service/object/add

 

body: json example: {“domain”:”10.224.64.225″,”user”:”6731″} or [{“domain”:”10.224.64.225″,”user”:”6731″},{“domain”:”10.224.64.13″,”user”:”6732″}]

Response: response code:200

  • flush all resource
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/drain

 

Response: response code:200

  • get idle resource number
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/idle

 

Response: response code:200 response body: number

  • get pools resource amount info
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/idle

 

Response: response code:200 response body: {“idleNumber”:3,”borrowedNumber”:3,”totalNumber”:6}

  • query current enabled resource factory
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/getFactory

 

Response: response code:200 response content: such as com.googlecode.common.remote.pool.resource.DefaultResourceFactory

  • list all resource in pool
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/list

 

Response: response code:200 response content: “no any resource” or {file=1.txt, owner=jiafu}:2014-04-28 14:29:34

client style

The client’s code amount is so small that you can copy the code directly.

 

        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.CommonRemotePoolClient(String)
        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.borrowObject(Class<T>)
        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.returnObject(Object)
        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.addObject(Object...)

Dependence:

        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jackson-provider</artifactId>
          <version>2.3.1.GA</version>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-client</artifactId>
          <version>3.0.2.Final</version>
        </dependency>

How to manage resource

you can manage resource by default implement.

Open source: server-test-toolkit

SST is an open source project which is designed for test automation of server applications.

 Code

Code SVN: https://server-test-toolkit.googlecode.com/svn/trunk/

Apache Maven: http://search.maven.org/#browse%7C779006397

<dependency>
   <groupId>com.googlecode.server-test-toolkit</groupId>
   <artifactId>server-test-toolkit</artifactId>
   <version>2.2.6</version>
</dependency>

Release Version: http://code.google.com/p/server-test-toolkit/wiki/ReleaseVersion?ts=1398301402&updated=ReleaseVersion

 Features

– Remote Shell Tool

  • Feature; shell commands’ execute and results retrieve based on remote linux server;
  • Use: grep server logs, modify config, block connection, get cpu/io/memory/swap performance data etc.

– Remote Storage Tool

  • Feature: download/upload file with remote ftp/sftp server;
  • Use: prepare and use test data in one centra ftp/sftp server.

– Random File Tool

  • Feature: generate several kinds of file: doc/txt/jpg/pdf for test data
  • Use: test data prepare, used for storage applications.

– General DB Access Tool

  • Feature: access db and do operations.
  • Use: check records in database

– Job Schedule Tool

  • Feature: encapsulate quartz to supported job config/execute and register mbean for monitor support
  • Use: define some jobs to do some tasks.

– Popular Services Access Tool

  • Feature: provide the access interfaces for popular services such as memcached/zookeeper
  • Use: server applications often contain popular open source services, so this tool provide the common access methods for popular ones.

– Effetive Util tool

  • Feature: disk/io/memory/trackid/sleep/validation/performance etc
  • Use: util tool will help coder code more effectivly

 Feedback

Welcome to contact me with email:fujian1115@gmail.com if you has followed cases:

– Bugs or Issues

– Design improve advices

– Other uncovered requirements

Thanks for your sharing!

Open source: testcase-annotation

We can use @testcase to write test case for java methods and generate them to one excel and html.

#Why_write_this_tool

#Requirements

#How_to_use_it

#More_use_examples

#FAQ

Why write this tool

In traditional test process, we are familiar with writing test cases in excel at first and then to implement the test cases’ automation one by one. At last,we add the java doc to every test method.

The problem is that when we change the test cases in excel we should found where is the related test scripts and located the code and change the test case java doc description to keep same.

On the other hand, for coder, they may like to write the test code as first and write test case in excel at later time.Maybe somebody doesn’t like any doc. So the tool can help them to generate the test cases in excel by automation.

Also the tool can provide the html style test case so that it can be integrated with Jenkins. Having it, you can check the daily run test cases in Jenkins and from the cases description you also can locate the position easier.

Requirements

1.maven project

How to use it

step 1: configure pom.xml

add followed two configure parts:dependency and plugin into pom.xml: note: the dependency’s last version can check the maven central:http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.googlecode.testcase-annotation%22

ALERT pls use the latest version.

<dependency>
    <groupid>com.googlecode.testcase-annotation</groupid>
    <artifactid>testcase-annotation</artifactid>
    <version>1.1.1</version></dependency>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>1.0-alpha-5</version>
    <configuration>   
        <factory>
        com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
        </factory>
    </configuration></plugin>

step 2: use @TestCase in your code

publicclassNewTest{


        @TestCase(
                        module="module one",
                        id =1,
                        title ="case title 1",
                        preConditions={"condition"},
                        steps ={
                                "case step one",
                                "case step two"
                                },
                        results ={
                                "case result one",
                                "case result two"
                                  }
                 )
        @Test
        publicvoidYourTestMethod(){

        }
        
}

step 3: generate excel and html(with excel content)

execute: mvn apt:process or apt:test-process

the goals can refer to :http://mojo.codehaus.org/apt-maven-plugin/plugin-info.html

output excel’s dir: it is decided to outputDirectory configure by default: http://mojo.codehaus.org/apt-maven-plugin/process-mojo.html#outputDirectory

  • for apt:process, the output dir is targetgenerated-resourcesapt
  • for apt:test-process, the output dir is targetgenerated-test-sourcesapt

More use examples

Use 1: How to generate office 03xls excel file instead of 07xlsx’s?

add option: excelType=xls

<configuration><factory>
com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl</factory><options>
    <option>excelType=xls</option></options></configuration>

Use 2: How to change the excel’s name instead of TestCase_Date.xlsx?

the excel file’s name is TestCase_Date.xlsx format. if you want to change it, you can:

add option: excelType=xls

<configuration><factory>
com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
</factory><options>
    <option>fileName=customizedName.xlsx</option></options></configuration>

Use 3: How to change the excel’s output dir instead of using outputdirectory ?

add configure: outputdirectory:

<configuration><factory>
com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
</factory><outputdirectory>C:aptDir</outputdirectory></configuration>

Use 4: How to bind to other maven lifecycle phrase?

if want to bind to test,add the executions to maven apt plugin:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>1.0-alpha-5</version>
    <configuration>                                      
    <factory>
    com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
    </factory>    
    </configuration>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>process</goal>
                <goal>test-process</goal>
           </goals>
        </execution>
    </executions></plugin>

and run mvn test can trigger both process and test-process for maven apt

Use 5: How to integrated with Jenkins?

1. set the output file to fixed name: can refer to <use 2> add set the option forceCreateFile to create file no matter is there any cases created so that the html publish plugin not to report build fail when no cases existed.

 <option>forceCreateFile=true</option>

whole configure:

<configuration><factory>
com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
</factory><options>
    <option>fileName=customizedName.xlsx</option>
    <option>forceCreateFile=true</option></options></configuration>

2. configure the jenkins’ job with html publish plugin

the result is similar with:

FAQ

Problem 1: java.lang.NoClassDefFoundError: org/apache/poi/ss/formula/udf/IndexedUDFFinder

the root cause is that:

the tool use 3.10’s poi dependency version, but if your pom.xml had existed lower verison for it which not supported IndexedUDFFinder, it will popup the error.

the solution is to remove the dependency for the lower’s version’s. for jar dependency can use exclude configure such as followed configure:

<dependency>
  <groupId>com.googlecode.server-test-toolkit</groupId>
  <artifactId>server-test-toolkit</artifactId>
  <version>1.0</version>
  <type>jar</type>
  <scope>compile</scope>
  <exclusions>
    <exclusion>
        <artifactId>poi</artifactId>
        <groupId>org.apache.poi</groupId>
    </exclusion>
  </exclusions></dependency>

Problem 2: how to format the annotation to good style

change the eclipse’s formmater:

->windows->preferences->java->code style->formmater ->Line Wrapping

Problem 3: jenkins: html publish plugin report build fail when no any cases existed

set the option to force creating file so that it can avoid copy fail.

<configuration><factory>
com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
</factory><options>
    <option>fileName=customizedName.xlsx</option>
    <option>forceCreateFile=true</option></options></configuration>

Problem 4: error: annotations are not supported in -source 1.3

the jdk1.3 not support annotations. so you can change maven compile plugin’s compile level to 1.6.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <encoding>UTF-8</encoding>
    </configuration></plugin>

Problem 5: can’t show Chinese rightly in excel

should config encoding method.

<plugin><groupId>org.codehaus.mojo</groupId><artifactId>apt-maven-plugin</artifactId><version>1.0-alpha-5</version><configuration><factory>com.googlecode.testcase.annotation.AnnotationProcessFactoryImpl
</factory><encoding>UTF-8</encoding></configuration></plugin>