Files
java-interview-lab/junit-mockito/scripts/compare-5-vs-6.sh
T
asmhatreandClaude Sonnet 5.5 715036b640 Add junit-mockito module: 30 runnable JUnit 6.1.3 / Mockito 5.24.0 interview answers
One test per question, each writing and asserting its own transcript under output/.
Covers lifecycle, extensions, parameterized and dynamic tests, mocks vs spies,
verification, strict stubs, static and constructor mocking, and flaky tests.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CifR2BE7PBvRy5hT8TS9oz
2026-10-26 01:52:44 +00:00

21 lines
1008 B
Bash
Executable File

#!/usr/bin/env bash
# Q2: compares the real junit-jupiter-api 5.14.4 and 6.1.3 jars. Writes output/q02-jar-comparison.txt.
# Needs JDK (javap, unzip) and Maven. Downloads both jars into the local Maven repository.
set -euo pipefail
cd "$(dirname "$0")/.."
unset JAVA_TOOL_OPTIONS
REPO="${HOME}/.m2/repository"
OUT=output/q02-jar-comparison.txt
TMP="$(mktemp -d)"
: > "$OUT"
for v in 5.14.4 6.1.3; do
mvn -B -q dependency:get -Dartifact="org.junit.jupiter:junit-jupiter-api:$v" >/dev/null
jar="$REPO/org/junit/jupiter/junit-jupiter-api/$v/junit-jupiter-api-$v.jar"
mkdir -p "$TMP/$v"
unzip -q -o "$jar" 'org/junit/jupiter/api/Test.class' -d "$TMP/$v"
major=$(javap -v -cp "$TMP/$v" org.junit.jupiter.api.Test | grep 'major version' | awk '{print $3}')
alpha=$(unzip -l "$jar" | grep -c 'MethodOrderer\$Alphanumeric' || true)
echo "junit-jupiter-api $v : class-file major version $major (Java $((major-44))), MethodOrderer\$Alphanumeric entries in jar: $alpha" | tee -a "$OUT"
done
rm -rf "$TMP"