Closed nagkumar closed 1 year ago
Is AtomicInteger
integer supported..
Further guess work revealed that it is unable to create a counter class with there is no zero-argument constructor that is public.
public Counter()
{
this("");
}
I added this to counter method, then test case worked..
Need for public zero argument is a serious limitation of this framework also, its engine is still junit 4 not upgraded to junit 5..
@nagkumar Thanks for this. Without some help and a serious increase in free time, It's unlikely that I'm going to revamp junit-quickcheck for JUnit 5. See https://github.com/pholser/junit-quickcheck/issues/139.
Without a zero-arg constructor on Counter
, how would you propose to tell the Fields
generator how to instantiate the Counter
class? Perhaps you might use @From(Ctor.class)
instead of @From(Fields.class)
.
AtomicInteger
and kin from java.util.concurrent
are not supported out of the box. To have default generators in junit-quickcheck for them sounds like a reasonable request. In the meantime, you can create generators for these types on your own, and make them available for junit-quickcheck to discover. See https://pholser.github.io/junit-quickcheck/site/1.0/usage/other-types.html for help in doing this.
Would you mind to create a separate issue requesting support for java.util.concurrent.Atomic{Integer,Boolean,Long}
?
Perhaps you might use @From(Ctor.class) instead of @From(Fields.class).
It ends up with this error message..
X incrementing
com.pholser.junit.quickcheck.internal.ReflectionException: com.pholser.junit.quickcheck.internal.ReflectionException: class com.tejasoft.utils.Counter needs a single accessible constructor
Would you mind to create a separate issue requesting support for
java.util.concurrent.Atomic{Integer,Boolean,Long}?
When I add a default empty constructor in the Counter class even an atomic integer works...
@nagkumar If you use Fields
, there needs to be an accessible zero-arg constructor on the class representing the annotated parameter.
If you use Ctor, you need a single accessible constructor.
If you create a custom generator for your class, it can instantiate your class in whatever manner it pleases.
What change(s) to junit-quickcheck are you requesting?
What change(s) to junit-quickcheck are you requesting?
If you use Ctor, you need a single accessible constructor.
I have multiple constructors, can I not specify which one to use
What change(s) to junit-quickcheck are you requesting?
If you use Ctor, you need a single accessible constructor.
I have multiple constructors, can I not specify which one to use
No, you cannot. Your best bet is to make a generator for your class, and make junit-quickcheck aware of it. junit-quickcheck comes with a number of generators that you can use as a model.
Where counter is
and test case is