bygui86 / spring-testing

Spring Testing sample project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Testing sample project

Desciption

In this sample project we are exploring the different testing techniques using some test frameworks.

PLEASE NOTE: The purpose of this sample project is not to achieve a complete test coverage!

Tech stack

Application

  • Java 11 (no modules)
  • Maven Wrapper 3.x
  • Spring Boot 2.1.x

Testing

  • JUnit 4
  • Mockito
  • Assertj Assertions
  • Spring Boot test
  • Spring Cloud Contract

Build & run

Pre-requisites

No specific pre-requisites

Make (in every sub-project)

  • just compile

      make clean compile
    
  • build and run unit tests

      make clean build
    
  • install

      make install
    
  • run

      make run
    
  • debug

      make debug
    
  • run integration tests

      make integration-test
    
  • run all tests

      make test
    
  • docker

    • build image

        make docker-build
      
    • run container

        make docker-run
      
    • run container as daemon

        make docker-run-daemon
      
    • stop daemon container

        make docker-stop
      

Maven & Docker (in every sub-project)

  • just compile

      ./mvnw clean compile
    
  • build and run unit tests

      ./mvnw -Dtest=*UnitTest clean package
    
  • install

      ./mvnw clean install
    
  • run

      ./mvnw spring-boot:run -DskipTests -Dspring-boot.run.jvmArguments='$(MEM_OPTS) $(JMX_OPTS) $(OTHER_OPTS)'
    
  • debug

      ./mvnw spring-boot:run -DskipTests -Dspring-boot.run.jvmArguments='$(MEM_OPTS) $(JMX_OPTS) $(OTHER_OPTS) -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$(IMAGE_DEBUG_PORT)'
    
  • run integration tests

      ./mvnw -Dtest=*IntegrationTest -DfailIfNoTests=false test
    
  • run all tests

      ./mvnw test
    
  • docker

    • build image

        ./mvnw clean package
        docker build -f Dockerfile_local -t $(IMAGE_NAME):$(IMAGE_TAG) .
      
    • run container

        docker run --rm -it --name $(NAME) $(DOCKER_IMAGE_PORTS) --net bridge --add-host=$(DOCKER_HOST):$(DOCKER_IP) $(IMAGE_NAME):$(IMAGE_TAG)
      
    • run container as daemon

        docker run --rm -d --name $(NAME) $(DOCKER_IMAGE_PORTS) --net bridge --add-host=$(DOCKER_HOST):$(DOCKER_IP) $(IMAGE_NAME):$(IMAGE_TAG)
      
    • stop daemon container

        docker container stop -f $(NAME)
      

TODOs

  • fix issue on contract testing
  • random testing (?)
  • test containers

Related repos


Links

DONE
IN-PROG

/

TODO

Issues

Repos

About

Spring Testing sample project

License:Apache License 2.0


Languages

Language:Java 81.0%Language:Makefile 12.4%Language:Groovy 6.3%Language:Dockerfile 0.3%