为什么在 Spring Batch 测试中我需要 JobLauncherTestUtils 和 JobRepositoryTestUtils?

huangapple go评论86阅读模式
英文:

Why would I need JobLauncherTestUtils and JobRepositoryTestUtils in Spring Batch Testing?

问题

为什么在测试Spring Batch项目时需要使用JobLauncherTestUtils和JobRepositoryTestUtils,而不是JobLauncher和JobRepository?它们之间有什么区别?

英文:

Why would I need to use JobLauncherTestUtils and JobRepositoryTestUtils instead of JobLauncher and JobRepository in testing Spring Batch project? What are their differences?

答案1

得分: 1

JobLauncherTestUtils具有以下优势:

  • 能够运行作业中的单个步骤
  • 能够为每次运行获取唯一的JobParameters实例

JobRepositoryTestUtils具有以下优势:

  • 提供实用方法来创建可用作测试装置的JobExecution实例
  • 提供了删除特定JobExecution或清理整个作业存储库的实用方法(在每个测试之后或之前非常有用)

有关更多详细信息,请参阅每个类的javadoc。

英文:

JobLauncherTestUtils has the following advantages:

  • Ability to run a single step in a job
  • Ability to get a unique JobParameters instance for each run

JobRepositoryTestUtils has the following advantages:

  • Utility methods to create JobExecution instances which can be used as test fixtures
  • Utility methods to remove specific JobExecutions or cleanup the entire job repository (useful after or before each test)

Please refer to the javadoc of each class for more details.

huangapple
  • 本文由 发表于 2020年10月16日 02:24:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/64377617.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定