how to write test case in java

前端 未结 1 872
予麋鹿
予麋鹿 2020-12-12 06:19

hi I created one class ABC.java, and there is one constructor ABC() as follows:

 public class ABC {

        private static String host;
        private         


        
相关标签:
1条回答
  • 2020-12-12 06:59

    Although Selenium is a test tool itself, it sounds to me as if you want to test this class itself. Like implementing a test with jUNit.

    With the snippet you just provided, there's not much to test, because you don't change the objects state (yet). The instance variables are not initialized (yet). The constructor does something but does not produce a result.

    You could write a pretty small test case to check if there's not Exception being thrown during initialization. Although this may be difficult, because you catch exceptions in the constructor.

    And you may consider redirecting System.out to a string during the test and check if the code prints the expected output to the console.

    0 讨论(0)
提交回复
热议问题