Git Product home page Git Product logo

unittestingdemoproject's Introduction

Unit Testing demonstration project

Build Status codecov Coverage Status License: MIT

Overview

This is a Java project serving as a brief demonstration for Unit Testing for the needs of the lab tutorials of the Software Engineering in Practice course. It makes use of Maven to automate the build process of the two available modules.

Requirements

This project requires:

Build project

In order to build the project execute the following Maven command:

mvn clean install

This command will also generate a report of the code coverage produced by JaCoCo. The report will be located in the following path for each module:

target/site/jacoco

Test project

To simply run the unit tests of the project, execute the following Maven command:

mvn test

Important: Note that only classes with a Test suffix located in the src/test will be executed and reported as Tests.

Continuous Integration

This projects utilizes TravisCI services in other to test and build the application upon each git-push in the remote repository. There are multiple build environments in which the application will be tested and build. You can check these options under the jdk tag in the .travis.yml file.

After each build, the badge is updated with the corresponding build status, green for passes and red for failures.

Here is a TravisCI quick guide. It's free for public repositories!

Code coverage

The repository is connected to two different code coverage analysis tools, CodeCov and Coveralls. Both code coverage services provide badges with the coverage percentages.

CodeCov

Code coverage reports provided by CodeCov is available on the repository page in the CodeCov website. The analysis is executed after each successfully TravisCI build.

CodeCov can use a more elaborated code coverage report that is produced by including the following plugin in your POM file.

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>cobertura-maven-plugin</artifactId>
	<version>2.7</version>
	<configuration>
		<formats>
			<format>html</format>
			<format>xml</format>
		</formats>
		<check />
	</configuration>
</plugin>

In order to produce the cobertura coverage report include the cobertura:cobertura in your mvn command.

The command for triggering the code coverage analysis should be placed in the .travis.yml as illustrated below

after_success:
  - bash <(curl -s https://codecov.io/bash) -t your_token 

The -t your_token is required only for private respositories.

In order to obtain a badge codecov in your README that reports the coverage of your project copy-paste the Markdown link provided by CodeCov in the repository's Settings-->Badge-->Markdown. Note that if you have a private repository the badge requires a ?token=a_token variable in the provided url. Otherwise it will always shows "unknown".

Here is a short example for using CodeCov with TravisCI in a Java project.

Coveralls

Coveralls is a stand alone code coverage analysis tool. However, it can be used as an analyser for the JaCoCo report produced during the package Maven command. In this repository we utilize Coveralls with its later functionality.

For parsing the JaCoCo output and creating a code coverage report, the jacoco:report coveralls:report arguments should be added in the Maven command in the .travis.yml file.

mvn clean package jacoco:report coveralls:report

Also, the Coveralls plug-in along with the repository Token (produced automatically by the Coveralls website) should be added in the pom.xml file like the following:

<plugin>
    <groupId>org.eluder.coveralls</groupId>
    <artifactId>coveralls-maven-plugin</artifactId>
    <version>4.3.0</version>
    <configuration>
        <repoToken>yourRepositotyToken</repoToken>
    </configuration>
</plugin>

Important: Coveralls is free only for public repositories.

Contributing

You are more than welcome to contribute in this project. Just have in mind that the repository aims at providing an overview of unit testing functionality and Continuous Integration plug-ins related to testing.

  • If you have any suggestions please open an issue.
  • If you want to actively contribute, please fork this repository and create a pull request after completing your addition/modification.

License

License: MIT

unittestingdemoproject's People

Contributors

antonisgkortzis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.