Junit testing for a boolean method

后端 未结 3 1725
一个人的身影
一个人的身影 2021-01-12 02:11

I have problem writing a testcase to this method below: EvenNum(double)

public class OddEven {

/**
 * @param args
 */

public boolean evenNum(d         


        
3条回答
  •  囚心锁ツ
    2021-01-12 02:40

    This seems like testing gone mad to me, and programming gone mad too. All the method does is evaluate num % 2 == 0. You may as well just code that everywhere required and throw away both the method and its tests. If you must keep the method, it relies on a mathematical identity, you don't need to test those. You may as well test 1+1==2.

提交回复
热议问题