You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/11/09 20:52:06 UTC

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #3279: Fix #3276 to make sure all objects have been deleted after each test …

ppalaga commented on a change in pull request #3279:
URL: https://github.com/apache/camel-quarkus/pull/3279#discussion_r746027414



##########
File path: integration-test-groups/aws2/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/Aws2S3Test.java
##########
@@ -36,6 +37,19 @@
 @QuarkusTestResource(Aws2TestResource.class)
 class Aws2S3Test {
 
+    @AfterEach
+    public void after() {
+
+        // Make sure all create objects have been deleted
+        final String[] objects = RestAssured.given()
+                .get("/aws2/s3/object-keys")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body().as(String[].class);
+        Assertions.assertTrue(objects.length == 0);

Review comment:
       > Is it good idea to put assertions in @AfterEach ?
   
   My understanding is that this `@AfterEach` assertion is intended much more as a check that the test has no leaks than an ordinary assertion checking the behavior of the application under test. Hence +1 for me.
   
   > Would each test be successful only when objects.length ==0, maybe we could assert at the end of each test ?
   
   `@AfterEach` has the advantage that it holds for all current and future test methods. If a method gets added in the future that leaks objects, the author will get notified early.
   
   > Would objects.length==0 show a situation where the tests execution is not satisfying, maybe throwing an exception is better ?
   
   Well, the assert method throws an AssertionError. Not sure what else could we do for making the test execution fail?




-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org