Mehraj Malik
Mehraj Malik

Reputation: 15874

Writing concurrent JUnit for Non-Concurrent Program

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 :

  1. Is it valid to write concurrent junit for non-concurrent code?
  2. If yes, what I should try to JUnit in that except the normal flow? as there is not shared/mutable property.

Upvotes: 3

Views: 139

Answers (1)

PrasadU
PrasadU

Reputation: 2438

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

  1. yes it should be tested

  2. 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. )

Upvotes: 4

Related Questions