Coder Social home page Coder Social logo

api-spark-sonar-demo's Introduction

rest-assured-api-spark-sonar-demo [API Tests]

Dependencies

Make sure you have installed on your operating system:

Execution

The following steps should get you set up for running tests locally on your machine:

a). Clone this repository to your local machine: git clone ssh://[email protected]:7999/~e6fpk5u/rest-assured-api-spark-demo-sonar.git
b). All commands should be run from the \rest-assured-api-spark-sonar-demo directory cloned during setup process above.

Stages Ver. 0.1

  1. Components testing. Runtime WebService (Jetty - 9.4.12.v20180830 - http://localhost:7779)

     a) Partially covered - $ mvn clean site -DtNG=Component -Pjacoco-ut
     b) Fully covered - $ mvn clean site -DtNG=Component_Full -Pjacoco-ut
     c) Save [ target/jacoco.exec ] - components code coverage
    
  2. Run WebContainer (Tomcat - 9.0.27 - http://localhost:7778) with VM arguments for jacoco agent

     a) Setup [CATALINA_OPTS="$CATALINA_OPTS -javaagent:~/.m2/repository/org/jacoco/org.jacoco.agent/0.8.1/org.jacoco.agent-0.8.1-runtime.jar=destfile=~/WorkSpace/rest-assured-api-spark-demo-sonar/jacoco-it/jacoco-it.exec,includes=*,append=false,output=file"]
     b) macOS: $ Tomcat/bin/startup.sh
     c) http://localhost:7778/manager/html
    
  3. Deploy (war)

     a) $ mvn -Ptc_l tomcat7:undeploy && mvn clean site -DtNG=Component_Full -Ptc_l tomcat7:deploy
    
  4. Integration testing

     a) http://localhost:7778/manager/html
     b) Full - $ mvn clean site -DtNG=Component_Full -Duri=localhost/v1 -Dport=7778
    
  5. Stop WebContainer

     a) macOS: $ Tomcat/bin/shutdown.sh
     b) Save [ jacoco-it/jacoco-it.exec ] - integration code coverage
    
  6. Generate Java Code Coverage report - Using jacoco maven plugin

     a) $ mvn jacoco:report-integration -Pjacoco-ut (OR $ mvn org.jacoco:jacoco-maven-plugin:0.8.5:report-integration -Pjacoco-ut)
    
  7. Generate Java Code Coverage report - Using SonarQube

     a) SonarQube V=7.9.1
     	1) $ docker run -d --name sonarqube -p 9091:9000 sonarqube:latest (OR $ docker start sonarqube)
     	2) $ docker ps
     	3) $ mvn sonar:sonar -Dsonar.username=admin -Dsonar.password=admin -Dsonar.host.url=http://127.0.0.1:9091
    
     b) SonarQube V=5.6.7 
     	1) $ docker run -d --name sonarqube_old -p 9092:9000 sonarqube:5.6.7-alpine (OR $ docker start sonarqube_old)
     	2) $ docker ps
     	3) $ mvn sonar:sonar -Dsonar.username=admin -Dsonar.password=admin -Dsonar.host.url=http://127.0.0.1:9092
     	
     c) Stop Docker - $ docker stop sonarqube sonarqube_old (docker start sonarqube sonarqube_old)
    

Stages Ver. 0.2

  1. Components testing. Runtime WebService (Jetty - 9.4.12.v20180830 - http://localhost:7779)

     a) Partially covered - $ mvn clean site -DtNG=Component -Pjacoco-ut
     b) Fully covered - $ mvn clean site -DtNG=Component_Full -Pjacoco-ut
     c) Save [ target/jacoco.exec ] - components code coverage
    
  2. Run WebContainer (Tomcat - 9.0.27 - http://localhost:7778) with VM arguments for jacoco agent

     a) Setup [CATALINA_OPTS="$CATALINA_OPTS -javaagent:~/.m2/repository/org/jacoco/org.jacoco.agent/0.8.1/org.jacoco.agent-0.8.1-runtime.jar=destfile=~/WorkSpace/rest-assured-api-spark-demo-sonar/jacoco-it/jacoco-it.exec,includes=*,append=false,output=file"]
     b) macOS: $ Tomcat/bin/startup.sh
     c) http://localhost:7778/manager/html
    
  3. Deploy (war)

     a) $ mvn -Ptc_l tomcat7:undeploy && mvn clean site -DtNG=Component_Full -Ptc_l tomcat7:deploy
    
  4. Integration testing

     a) http://localhost:7778/manager/html
     b) Full - $ mvn clean site -DtNG=Component_Full -Duri=localhost/v1 -Dport=7778
    
  5. Stop WebContainer

     a) macOS: $ Tomcat/bin/shutdown.sh
     b) Save [ jacoco-it/jacoco-it.exec ] - integration code coverage
    
  6. Generate Java Code Coverage report - Using jacoco maven plugin

     a) $ mvn jacoco:report-integration -Pjacoco-ut (OR $ mvn org.jacoco:jacoco-maven-plugin:0.8.5:report-integration -Pjacoco-ut)
    
  7. Generate Java Code Coverage report - Using SonarQube

     a) SonarQube V=7.9.1
     	1) $ docker run -d --name sonarqube -p 9091:9000 sonarqube:latest (OR $ docker start sonarqube)
     	2) $ docker ps
     	3) $ mvn sonar:sonar -Dsonar.username=admin -Dsonar.password=admin -Dsonar.host.url=http://127.0.0.1:9091
    
     b) SonarQube V=5.6.7 
     	1) $ docker run -d --name sonarqube_old -p 9092:9000 sonarqube:5.6.7-alpine (OR $ docker start sonarqube_old)
     	2) $ docker ps
     	3) $ mvn sonar:sonar -Dsonar.username=admin -Dsonar.password=admin -Dsonar.host.url=http://127.0.0.1:9092
     	
     c) Stop Docker - $ docker stop sonarqube sonarqube_old (docker start sonarqube sonarqube_old)
    

Static Analysis

  • mvn clean -Pstatic-analysis site -Dmaven.test.skip=true

Reports

In project exist 5 kinds of reports:

  • TestNG produces ‘index.html‘ report and it resides in the same test-output folder. This report gives the link to all the different components of the TestNG report like Groups & Reporter Output.

  • SureFire report. The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application.

  • Allure report. An open-source framework designed to create test execution reports clear to everyone in the team.

  • JaCoCo report. The JaCoCo provides the JaCoCo runtime agent to your tests and allows basic report creation.

  • SonarQube service. SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities.

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.