Skip to content

ivanroma20/demo

 
 

Repository files navigation

Demo - demonstrates an application and tests

This is an application by Coveros to demonstrate good software practices.

Quick Start:

  • You must have javac available in your PATH (see JDK notes)
  • Clone or download this repo. (if you download, unzip the file to a directory.)
  • On the command line in the top directory of this repo, run gradlew apprun
  • Visit the application with your browser at http://localhost:8080/demo

Summary:

Demo consists of a simple web application and tests. Its goal is to provide an environment suitable for demonstration and practice in valuable development techniques. Some of the techniques exemplified are:

Its essential goals:

  • Just works, any platform.
  • As simple as possible
  • Minimal system requirements
  • Fast and easy to install and to run
  • High test coverage
  • Multiple business domains
  • Easy to maintain and improve
  • Well documented
  • High performance
  • Illustrates maximum number of techniques
  • Easy to get up to speed

Table of contents:

  1. Optional dependencies
  2. Java installation notes
  3. Chromedriver installation notes
  4. Python installation notes
  5. To build and run tests
  6. To run the application
  7. To run API and UI tests
  8. Summary of relevant Gradle commands
  9. The whole shebang - CI/CD pipeline
Optional Dependencies

If you want API testing and Selenium testing, you will need to visit these links and download / install the applications found there.


Java installation notes

To install: download the development kit, make note of the installation directory. Add that directory to your path. For example, on Windows, press the Windows button, type "env" to edit the environment variables for your account. Under user variables click New and add:

  • Variable name: JAVA_HOME
  • Variable value: C:\Program Files\Java\jdk-11.0.5 replace this with the correct path

Click OK. Click the PATH user variable and click edit, and then click New, and add a new line for Java as follows:

%JAVA_HOME%\bin

Test this out by opening a command terminal, for example run the program called "cmd", and run this:

javac -version

You should get something similar to the following:

C:\Users\byron>javac -version
javac 11.0.5

Now you are ready!

Chromedriver installation notes

make sure that the Chromedriver executable is installed in one of the directories that is on your path. To see your path, type the following in a command line:

on Windows:

echo %PATH%  

On Mac/Linux:

echo $PATH

If you run the command, chromedriver on the command line, you should get a result similar to this:

Starting ChromeDriver ...

Python installation notes

Python can be downloaded here

To run API tests and Selenium tests, an easy way to handle its dependencies is to use pipenv. To get this installed, first download get-pip.py, and run the following on the command line:

python get-pip.py

Then,

pip install pipenv

And in the demo directory,

pipenv install   

To build and run tests:

On the command line, run the following:

On Mac/Linux

./gradlew check

On Windows

gradlew check

To run the web application:

On the command line, run the following:

On Mac/Linux

./gradlew apprun

On Windows

gradlew apprun

Then, head to http://localhost:8080/demo

To run API and UI tests:

Note: The app has to be already running for these tests to pass, and you need to have installed [Python] and [Chromedriver].

In a new terminal, separate from the one where the server is running, run the following:

On Mac/Linux

./gradlew runAllTests

On Windows

gradlew runAllTests    

Summary of relevant Gradle commands

  • gradlew apprun - runs the application

  • gradlew check - runs all tests possible with only dependency being Java 8. No need for app to be running.

  • gradlew runAllTests - runs the whole set of tests**

  • gradlew clean - cleans build products and installs pre-push hook. (see the file in this directory, pre-push)

  • gradlew runBehaveTests - runs the UI tests**

  • gradlew runApiTests - runs the API tests**

  • gradlew generateCucumberReport - runs cucumber and creates a nice-looking HTML report

  • gradlew pitest - runs mutation testing (see http://pitest.org/)

  • gradlew dependencyCheckAnalyze - analyzes security reports for the dependencies of this project. See https://www.owasp.org/index.php/OWASP_Dependency_Check

  • gradlew sonarqube - runs static analysis using SonarQube. Sonarqube must be running - check http://localhost:9000

  • gradlew fastIntegrationTest - runs the database integration tests

  • gradlew startH2Console - Starts a console to examine the H2 database file. (user and password are empty, URL to use is jdbc:h2:./build/db/training)

  • gradlew <task 1>... taskTree - a utility that will show the task tree for a particular task

    ** Requires the app to be running (usually in another terminal) and all optional dependencies installed.

The whole shebang - a CI/CD pipeline

Details on building out a CI/CD pipeline are found in the "docs/ci_and_cd" directory. For example, to set it all up on a local Windows box

Features of the pipeline:
  • A fully functioning demonstration CI/CD pipeline using Jenkins.
  • Incorporates static analysis using SonarQube
  • UI tests running on Chrome

##Screenshots: Cucumber report Feature file Jenkins pipeline Webapp Zap attach proxy SonarQube analysis Running performance tests

About

A demonstration of a web application with tests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 76.1%
  • Python 7.7%
  • Gherkin 5.4%
  • TSQL 4.6%
  • HTML 2.7%
  • JavaScript 1.8%
  • Other 1.7%