mureinik commented on code in PR #4484:
URL: https://github.com/apache/eventmesh/pull/4484#discussion_r1359249974
##########
eventmesh-sdks/eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/grpc/producer/EventMeshGrpcProducerTest.java:
##########
@@ -93,11 +94,7 @@ public void setUp() throws Exception {
@Test
public void testPublishWithException() {
- try {
-
producer.publish(defaultEventMeshMessageBuilder().content("mockExceptionContent").build());
- } catch (Exception e) {
- assertThat(e).isNotNull();
- }
+ Assertions.assertDoesNotThrow(() ->
producer.publish(defaultEventMeshMessageBuilder().content("mockExceptionContent").build()));
Review Comment:
@pandaapo looking through the history for both this test and the class it's
supposed to test, it seems this test never did anything too useful - the call
to `publish` just succeeded, and the test implicitly passed without calling any
assertion.
Following your suggestion, I added another commit to explain this and fix
the test in the old style by calling `publish` with an argument that's clearly
invalid (just a string literal) and asserting that an exception was indeed
thrown (see
https://github.com/apache/eventmesh/pull/4484/commits/34cd378f5794390d470bd29d5c688dd874684fa5)
and then refactored it away to use `assertThrows` in the "main" commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]