Java unit test for different input data

前端 未结 2 1990
忘掉有多难
忘掉有多难 2020-12-16 18:45

I need to test some api. For example I have multiple @Test methods in the class to test my functionality, before init I connect to some url of my service, and use it.

2条回答
  •  庸人自扰
    2020-12-16 19:21

    there are prameterized tests: http://www.mkyong.com/unittest/junit-4-tutorial-6-parameterized-test/ and http://ourcraft.wordpress.com/2008/08/27/writing-a-parameterized-junit-test/.

    alternatively, you can make your test case abstract and subclass it with each subclass setting up the url.

提交回复
热议问题