'Junit: how to handle class level variables in junit test cases

In the below incrementId() method, I need to test id > MAX_NUM greater than the condition.

pubic class ClassATest {

  AtomicInteger atomicInt = new AtomicInteger (0)
  public static final int MAX_NUM = 1000

  pulic long incrementId() {
   long id = atomicInt.incrementAndGet();
   if (id > MAX_NUM ) {
     System.out.println("need to be tested....")
   }
}
}

Is it possible to mock the above atomicInt object? or is there any way to test above if condition without affecting the performance?

Can someone please help me on this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source