简体   繁体   中英

Spring JUnit4 Group integration tests

I have multiple integration test that starts a mock socket server, send message to it and verify the response. All of these tests starts the same mock server. I want to group these tests and achieve following execution flow.

  1. Start Server
  2. Load Spring context
  3. Execute all tests (since they all send messages to same server
  4. Close Spring Context
  5. End the Server

I also want to run any of these test on individual bases ie running only one test.

Can anyone please guide me how I can structure my test classes?

Thanks

you have at least to ways. if you use maven you can assign server startup to pre-integration-test and server shutdown to post-integration-test phase. it's usually done with jetty/tomcat. other way is to use testng and use beforeGroup/beforeClass and afterGroup/afterClass to startup and shutdown your server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM