-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintenance/use more junit5 features #518
Maintenance/use more junit5 features #518
Conversation
… another tests the existence of the pojo.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #518 +/- ##
============================================
+ Coverage 82.11% 82.16% +0.04%
+ Complexity 478 390 -88
============================================
Files 86 85 -1
Lines 1068 953 -115
Branches 70 68 -2
============================================
- Hits 877 783 -94
+ Misses 156 144 -12
+ Partials 35 26 -9 ☔ View full report in Codecov by Sentry. |
...c/spring/boot/chaos/monkey/endpoints/ChaosMonkeyRequestScopeRestEndpointIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ng-boot/src/test/java/de/codecentric/spring/boot/demo/chaos/monkey/ChaosDemoApplication.java
Outdated
Show resolved
Hide resolved
...spring/boot/chaos/monkey/watcher/outgoing/ChaosMonkeyRestTemplateWatcherIntegrationTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally found the time to check it out in more detail. I've left some comments.
The changes overall looks good, thanks for that 👍
There aren't really blocking points in my opinion, despite the @Disabled
test and the comment/review from @denniseffing.
After that feel free to (squash :D) merge (or address some of the further comments) :)
...est/java/de/codecentric/spring/boot/chaos/monkey/ChaosDemoApplicationDefaultProfileTest.java
Show resolved
Hide resolved
@@ -48,6 +50,9 @@ public void setup() { | |||
when(greetingServiceMock.greet()).thenReturn(responseService); | |||
responseRepo = "Hello from repo!"; | |||
when(greetingServiceMock.greetFromRepo()).thenReturn(responseRepo); | |||
when(greetingServiceMock.greetFromRepoPagingSorting()).thenReturn(responseRepo); | |||
when(greetingServiceMock.greetFromRepoJpa()).thenReturn(responseRepo); | |||
when(greetingServiceMock.greetFromRepoAnnotation()).thenReturn(responseRepo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also move this to the parametrized test below, because its only used there. However no hard feelings in keeping it here :D
@SpringBootTest(properties = {"chaos.monkey.enabled=true", "chaos.monkey.watcher.rest-template=true", "chaos.monkey.assaults.latency-active=true", | ||
"chaos.monkey.test.rest-template.time-out=20"}, classes = {ChaosDemoApplication.class}) | ||
@ActiveProfiles("chaos-monkey") | ||
static class LatencyAssaultIntegrationTest { | ||
@Nested | ||
@Disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that was added by accident? However it seems that the Exception has changed from SSLException to io.netty.handler.timeout.ReadTimeoutException
EDIT: This seems to work:
assertThatThrownBy(() -> demoRestTemplateService.callWithRestTemplate()).isInstanceOf(ReadTimeoutException.class);
@Mock | ||
private Advice advice; | ||
@Mock | ||
private ChaosMonkeyBaseClassFilter baseClassFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good changes 👍
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class HelloComponentTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which value adds this test? 😅 if its only to get codecov happy I would simply drop it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if codecov drops down, you have to merge it anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you fix that, im happy to merge it (or you can on your own if you like) :D
@@ -35,7 +37,7 @@ public class HelloControllerTest { | |||
@Autowired | |||
private MockMvc mockMvc; | |||
|
|||
@MockBean | |||
@MockitoBean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please do this change for the remaining @MockBean
as well if possible? 🙃🙏
final int latencyRangeStart = 1000; | ||
final int latencyRangeEnd = 5000; | ||
@Mock | ||
ApplicationEventPublisher applicationEventPublisher; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal taste: I would add private to every member variable here
|
||
assertThat(settings.getChaosMonkeyProperties()).isNotNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure, why this test existed before, however dont we need these notnull checks still in a test (allArgsTest?)?
BDDAssertions.then(watcherProperties.isRestTemplate()).isTrue(); | ||
BDDAssertions.then(watcherProperties.isWebClient()).isTrue(); | ||
BDDAssertions.then(watcherProperties.isActuatorHealth()).isTrue(); | ||
assertAll(() -> assertEquals(HttpStatus.OK, response.getStatusCode()), () -> assertTrue(watcherProperties.isController()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐼
Many Junit 5 features are not used in existing tests because the structures from JUnit 4 are still being implemented.
Mocks and other values e.g. can be injected directly into the tests without using the Mockito.mock method or class attributes.