In this sample project we are exploring the different testing techniques using some test frameworks.
- Java 11 (no modules)
- Maven Wrapper 3.x
- Spring Boot 2.1.x
- JUnit 4
- Mockito
- Assertj Assertions
- Spring Boot test
- Spring Cloud Contract
No specific pre-requisites
-
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
-
-
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)
-
- fix issue on contract testing
- random testing (?)
- test containers
- theory
- tests separation
- unit/integration testing
- https://www.baeldung.com/spring-boot-testing
- https://www.baeldung.com/injecting-mocks-in-spring
- https://www.baeldung.com/spring-boot-testresttemplate
- spring @restclienttest
- https://www.baeldung.com/restclienttest-in-spring-boot
- https://objectpartners.com/2013/01/09/rest-client-testing-with-mockrestserviceserver/
- https://www.dontpanicblog.co.uk/2016/07/16/resttemplatebuilder-and-restclienttest-in-spring-boot-1-4-0/
- https://examples.javacodegeeks.com/enterprise-java/spring/using-mockrestserviceserver-test-rest-client/
- feign client
- https://www.baeldung.com/integration-testing-in-spring
- https://www.baeldung.com/spring-webappconfiguration
- https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html
- web
- configurations
- contract testing
- https://martinfowler.com/articles/consumerDrivenContracts.html
- https://www.baeldung.com/spring-cloud-contract
- https://cloud.spring.io/spring-cloud-contract/
- https://spring.io/guides/gs/contract-rest
- https://cloud.spring.io/spring-cloud-contract/single/spring-cloud-contract.html
- multiple base classes
- dsl
- multiple contracts in one file
- pushing to repo
- pulling from repo
- maven properties
/
- theory
- unit/integration testing
- contract testing
- security testing
- wiremock
- cloud-native
- mock-server
- spock
- ?
- junit5
- spring-projects/spring-boot#6541
- https://moelholm.com/2016/10/22/spring-boot-separating-tests/
- https://stackoverflow.com/questions/47979589/spring-data-jpa-generate-id-on-database-side-only-before-create
- https://stackoverflow.com/questions/35232827/spring-boot-test-ignores-logging-level
- spring-cloud/spring-cloud-netflix#1482
- https://www.concretepage.com/questions/535
- https://www.mkyong.com/java/jackson-2-convert-java-object-to-from-json/
- https://stackoverflow.com/questions/43093968/enablefeignclients-and-feignclient-fail-on-autowiring-feigncontext-nosuchbea