简体   繁体   中英

How to write unit test cases for Spring Batch application that read from database and write to csv?

I have created one spring batch application that basically reads from a databse and write it into a csv file. The application has a job and one step. In that one step I am reading, processing and writing to the file. These tasks are done by reader, processor and writer respectively.

Now I want to write unit test cases for these all in Junit.

How should I go about it?

You can test your Spring Batch application using the @SpringBatchTest annotation. You can test jobs end to end or test individual steps.

If you have complex business logic in your processor you may also want to test that in isolation.

https://docs.spring.io/spring-batch/docs/4.3.x/reference/html/testing.html#testing

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