Configuring system tests in junit
We currently have a dedicated tool for running system tests on our web services, but I've been thinking of re-writing it to be hostable within jUnit4.
This would give us several advantages, including the full power of Java to set up and assert results, as well as hopefully a simpler method of running the tests (both from CI and the IDE).
However,开发者_如何学Go the tests would need a URL configured for it to test against (it is currently too impractical to initialise a local servlet for testing). Given this, is it still a good idea to try and host it in jUnit? If so, what's the best way to add the configuration?
It depends on how you will be running your unit tests. I normally use maven, then you have a test/resources directory where you can store the test setup.
You can use spring with AbstractDependencyInjectionSpringContextTests (which gives you spring-injected configuration, you can swap the main spring config for a test version)
Here is a dicussion about configuring junit in eclipse
If you're doing non-unit testing, TestNG might be a better option than JUnit. More specifically, data providers seem like they would be a good fit in the scenario you describe (example here). Data providers can retrieve their data pretty much from anywhere: a text/properties/xml/Excel file, a database, a remote host, etc...
精彩评论