#Unnecessary Stubbing Junit5

1 messages · Page 1 of 1 (latest)

blissful cairn
#

I have an unnecessary stubbing in my @formal saddlerametrized testing due to a short circuit of an if statement in my code. How can I fix that?

heavy valleyBOT
#

<@&987246399047479336> please have a look, thanks.

heavy valleyBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

pine creek
#

full code please

split merlin
#

poor Pa

#

he didn't saw this coming

blissful cairn
#
@BeforeEach
public void setup(){
when(foo.Enabled()).thenReturn(true)
 }

@ParameterizedTest
@ValueSource(booleans = {true, false})
void testFoo(boolean val) {
 when(foo.isTopic()).thenReturn(val);
// asserts bar.validate()
}

// bar.validate() method has
if(foo.isTopic() && !foo.isEnabled())
blissful cairn
#

Any idea @pine creek

#

@split merlin

split merlin
#

@blissful cairn i don't understand what u mean, can u noobify it?

blissful cairn
#

@split merlin basically bar.validate has an if statement and isTopic() is the first condition

#

If it evaluates to false

#

The isEnabled method is not called

#

I get an unnecessary stubbing error due to that since my parametrized test returns a false topic and Enabled doesnt ever get called

pine creek
#

show the full code and the full error message

#

until then, people are just waiting and wont help