How do you automate integration testing? I use JUnit for some of these tests. This is one of the solutions or is totally wrong? What do you suggest?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I've used JUnit for doing a lot of integration testing. Integration testing can, of course, mean many different things. For more system level integration tests, I prefer to let scripts drive my testing process from outside.
Here's an approach that works well for me for applications that use http and databases and I want to verify the whole stack:
Hypersonic or H2
in in-memory mode as a replacement for the database (this works best for ORMs)@BeforeSuite
or equivalent (again: easiest with ORMs)@Before
each test, clear the database and initialize with the necessary dataJWebUnit
to execute HTTP requests towards JettyThis gives you integration tests that can run without any setup of database or application server and that exercises the stack from http down. Since it has no dependencies on external resources, this test runs fine on the build server.
Here some of the code I use:
For those who'd like to know more, I've written an article about Embedded Integration Tests with Jetty and JWebUnit on Java.net.
There is a very good extension for JUnit called Jitr.
Jitr is a JUnit Integration Test Runner and it allows your web application integration tests to easily run against a lightweight web container in the same JVM as your tests.
See their site for details: http://www.jitr.org/
In our work here, our integration testing solution has three major parts:
The end result is that most people here never worry about integration testing: it just happens. Unit testing, on the other hand, is everyone's priority. JUnit makes it easy to construct tests, though good tests will always require thought and development time.
The suggestion depends on your application and your objective.
I've written integration tests in JUnit, but I've also seen people use HtmlUnit (JUnit extension), Selenium, Watir, Fit/Fitness, and even commercial tools like WinRunner and Silk.
So tell us a bit more about your domain and the objectives of your tests and you can probably get a better answer.