public class StepScopeTestExecutionListener
extends java.lang.Object
implements org.springframework.test.context.TestExecutionListener
TestExecutionListener
。StepContext
は、テストメソッドの実行中に作成され、注入されたすべての依存関係で使用できるようになります。デフォルトの動作は、固定プロパティを持つ StepExecution
を作成することです。または、正しい型を返すファクトリメソッドとしてテストケースで提供することもできます。例:@ContextConfiguration @TestExecutionListeners( { DependencyInjectionTestExecutionListener.class, StepScopeTestExecutionListener.class }) @RunWith(SpringJUnit4ClassRunner.class) public class StepScopeTestExecutionListenerIntegrationTests { // A step-scoped dependency configured in the ApplicationContext @Autowired private ItemReader<String> reader; public StepExecution getStepExecution() { StepExecution execution = MetaDataInstanceFactory.createStepExecution(); execution.getExecutionContext().putString("foo", "bar"); return execution; } @Test public void testStepScopedReader() { // Step context is active here so the reader can be used, // and the step execution context will contain foo=bar... assertNotNull(reader.read()); } }
コンストラクターと説明 |
---|
StepScopeTestExecutionListener() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterTestClass(org.springframework.test.context.TestContext testContext) |
void | afterTestMethod(org.springframework.test.context.TestContext testContext) |
void | beforeTestClass(org.springframework.test.context.TestContext testContext) |
void | beforeTestMethod(org.springframework.test.context.TestContext testContext) |
protected StepExecution | getStepExecution(org.springframework.test.context.TestContext testContext) StepExecution をテストケースのフィールドとして検出するか、利用できない場合は作成します。 |
void | prepareTestInstance(org.springframework.test.context.TestContext testContext) StepExecution をテストコンテキスト属性として設定します。 |
public void prepareTestInstance(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
StepExecution
をテストコンテキスト属性として設定します。org.springframework.test.context.TestExecutionListener
の prepareTestInstance
testContext
- 現在のテストコンテキスト java.lang.Exception
- 問題がある場合 TestExecutionListener.prepareTestInstance(TestContext)
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の beforeTestMethod
testContext
- 現在のテストコンテキスト java.lang.Exception
- 問題がある場合 TestExecutionListener.beforeTestMethod(TestContext)
public void afterTestMethod(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の afterTestMethod
testContext
- 現在のテストコンテキスト java.lang.Exception
- 問題がある場合 TestExecutionListener.afterTestMethod(TestContext)
public void afterTestClass(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の afterTestClass
java.lang.Exception
public void beforeTestClass(org.springframework.test.context.TestContext testContext) throws java.lang.Exception
org.springframework.test.context.TestExecutionListener
の beforeTestClass
java.lang.Exception
protected StepExecution getStepExecution(org.springframework.test.context.TestContext testContext)
StepExecution
をテストケースのフィールドとして検出するか、利用できない場合は作成します。testContext
- 現在のテストコンテキスト StepExecution