I am writing Junit test case for a method which does a job in background thread. To test the flow, I am planning to write a ExecutorService that I can use in my testcase. The ExecutorService should run the job in main thread. What I mean is that ExecutorService implementation should use the main thread to execute any task submitted to it. It must not create any worker thread. Anyone has sample code for that?
How to create Java ExecutorService object that runs task in main thread?
You must be signed in to leave a comment
19 June 2022, 08:22
Found the answer here.