Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

Where could these suppressed exceptions be coming from?

Ranch Hand
Posts: 69
Python Java Windows Linux
  • Mark post as helpful
  • send pies
  • 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: 69
Python Java Windows Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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:

It's a tiny ad only because the water is so cold.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!