thenReturn() normal mock'lar için varsayılan ve en okunabilir yöntemdir; sabit bir dönüş değeri tanımlamak istediğinizde tercih edilir.
doReturn() ise özellikle @Spy kullanılan durumlarda gerçek metodun çalışmasını engellemek için kullanılır. Böylece yan etkiler veya istenmeyen exception'lar önlenir.
Kısacası, mock için thenReturn(), spy için ise gerektiğinde doReturn() kullanmak en doğru yaklaşımdır.
If you are building AI agents with Spring AI, you are likely exploring the Model Context Protocol (MCP). MCP is a game-changer for AI applications, standardizing how AI models interact with external tools and data sources.
This guide demonstrates how to implement robust Behavior-Driven Development (BDD) integration tests using Cucumber in a Spring Boot Kotlin application with JWT authentication. The setup leverages Testcontainers for database isolation and provides a clean, maintainable testing architecture.