spring-test-slices: Spring Boot 4.1.2 test slices lab (@WebMvcTest, @JsonTest, @RestClientTest, @DataJpaTest vs @SpringBootTest)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7Jbw5CxUQ13D7gn25
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates every file in spring-test-slices/output/.
|
||||
# Needs JDK 25 and Maven on the PATH. Takes about a minute.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
OUT=output
|
||||
# keep transcripts free of JVM launcher noise that varies per machine
|
||||
filter() { grep -vE '^(Picked up JAVA_TOOL_OPTIONS|WARNING: )' || true; }
|
||||
|
||||
rm -f "$OUT"/*.txt
|
||||
mkdir -p "$OUT"
|
||||
|
||||
# 1. the whole suite: every test writes its own transcript to output/ and asserts the same facts
|
||||
mvn -B -q clean test 2>&1 | filter | grep -E 'Tests run:|BUILD|ERROR' || true
|
||||
|
||||
# 2. which test jars does spring-boot-starter-test alone bring in?
|
||||
./scripts/starter-test-only.sh
|
||||
|
||||
# 3. startup time of each context, one test class per JVM so nothing is cached.
|
||||
# Spring Boot logs "Started <TestClass> in N seconds" for every context it builds.
|
||||
# Timings vary by machine and by run: read them as indicative, not as a result.
|
||||
{
|
||||
echo "Context startup time per test class (one class per mvn run; indicative, varies between runs)"
|
||||
echo
|
||||
for cls in JsonSliceTest RestClientSliceTest WebMvcSliceTest DataJpaSliceTest FullContextTest; do
|
||||
mvn -B test -Dtest="$cls" 2>&1 | grep -oE "Started $cls in [0-9.]+ seconds" | head -1
|
||||
done
|
||||
} > "$OUT/30-startup-times.txt"
|
||||
|
||||
echo "done: $(ls "$OUT" | wc -l) files in $OUT/"
|
||||
Reference in New Issue
Block a user