Issue
We have a non-concurrent
java snippet to generate jwt token and now need to write JUnit
for the same.
There are few queries about this :
- Is it valid to write
concurrent junit
fornon-concurrent code
? - If yes, what I should try to
JUnit
in that except the normal flow? as there is notshared/mutable
property.
Solution
I think the term you are looking for is probably - 'thread safety'.
if you need to prove the code works in a multi-threaded scenario
yes it should be tested
if the code (class / object) is 'stateless' - the tests should be simpler -validate that output is only input or non-shared time/nonce based.
(you haven't shared code - so this is a general answer.
In your case if jwt token is being created - implies that - concurrent invocation will returns different token values. hence the assertions should confirm the same. )
Answered By - PrasadU