Kotlin (opens in new tab)
๐งช JUnit Test Isolation โ One Small Detail That Changed Everything Today I learned that JUnit creates a brand-new instance of your test class for every " "@TestInstance(TestInstance.Lifecycle.PER_METHOD)" What happens? "test1()" runs โ counter becomes "1" JUnit destroys that object "test2()" gets a fresh instance โ counter starts at "0" again and becomes "2" This prevents tests from accidentally sharing state and affecting each other. ๐ Bonus Gradle Gotcha: If your tests are inside "src/main/k...
Read the original article