• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Where could these suppressed exceptions be coming from?

 
Ranch Hand
Posts: 73
1
Python Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
* My question is about seeing some extra text when raising an exception:


- I don't know why this "Suppressed:" is added? I don't need this and I would like to clean it up.
- From what I've been able to research myself, Suppressed happens if the exception is thrown within a try-with-resources, but I am not using that anywhere!
(I am of course using a lot of try-catch, though not in any of the code path that raises these!)

Following is some code, maybe you could see what is causing the "Suppressed:"?
- My best guess right now is that JUnit5's reflection util, @AfterEach, has some tear down of local scope objects - but not sure if that's true and what I can do about it

--------

In my automation scripting framework, it has been established that the scripter knows best how to recover from a failed step.
Therefore, I've coded a "soft failing" exception system:
1. Script actions result in data, which can conditionally populate a field that stores errors:



2. At the end of the script, errors are raised:


3. Here's the full raiseSoftAssertions(); method:


4. Here's the custom exception class:


I know JUnit is for unit testing and unit tests need to explode violently rather than continue but I am making huge profits from JUnit's IDE/Maven integration and tagging system. So, please let me keep it there
 
Todor Kolev
Ranch Hand
Posts: 73
1
Python Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I had figured it out.
The whole question is worthless because none of the code is responsible for the excessive Suppressed error.

I will, however, share my findings, as I have learned something new:
The suppressed warning comes from calling raiseSoftAssertions inside a session object which is created inside the JUnit test.
This is not according to my design, where the session object is created in @BeforeEach but I was experimenting with more than one session in a test.

Here's what's going on:
1. JUnit executes the test
2. raiseSoftAssertions called inside a JUnit test raises an unsuppressed exception
3. JUnit still executes @AfterEach, which has its own raiseSoftAssertions call - but this exception will be raised suppressed, because it's considered
a secondary action, once a test had already raised an assertion error.

For illustration purposes, the actual test:


The above test class inherits EppTestRoot:

 
I knew that guy would be trouble! Thanks tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic