JUnit 4: Set up things in a test suite before tests are run (like a test's @BeforeClass method, just for a test suite)

后端 未结 4 437
梦谈多话
梦谈多话 2020-11-30 04:59

I want to do some functional testing on a (restful) webservice. The testsuite contains a bunch of test cases, each of which performs a couple of HTTP requests on the webserv

4条回答
  •  醉梦人生
    2020-11-30 05:25

    As an aside, it's a bad idea to have unit tests actually calling external resources like webservices, databases, etc.

    Unit tests should be super-quick to run and a delay of 'a couple of minutes' for each run of the suite will mean it won't be run as much as it should.

    My advice:

    Look at mocking external dependencies in unit tests with something like EasyMock (http://www.easymock.org/).

    Build a seperate suite of integration tests with something like Fitnesse (http://fitnesse.org/) or a homegrown solution that runs against a test environment and which is continually up.

提交回复
热议问题