java - JUnit testing recursive method -


i made 1 class recursive method checks if 2 arrays same, want test junit. question be:

what method should use test no value, negative value , limited value?

thanks in advance. best regards

ps: have done far:

 @test  public void testofthetests(){      system.out.println("test");      int[]a={1,2,3,4,5,6,7};      int[]b={7,6,5,4,3,2,1};      boolean result = main.equalshelper2(a,b,0,6);      boolean expresult=true;      // assertequals(expresult,result);      assert.assertnotnull(result); } 

what have read "no value, negative value , limited value" means, test different forms arrays can take, no value or negative doesn't apply case need think of test cases apply method.

here test cases might want add:

  • one array null
  • both arrays null
  • the arrays have different length
  • the elements in same order in both
  • the arrays have same elements in different order
  • if array indexes passed method invalid
  • ...
  • ...

here 2 examples:

@test  public void testequal(){      int[]a={1,2,3,4,5,6,7};      int[]b={7,6,5,4,3,2,1};      assert.assertequals(a,b);      assert.asserttrue(main.equalshelper2(a,b,0,6)); }   @test  public void testdifferent(){      int[]a={1,1,1,1,1,1,1};      int[]b={7,6,5,4,3,2,1};      assert.assertnotequals(a,b);      assert.assertfalse(main.equalshelper2(a,b,0,6)); } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -