Class FoxgloveTestListener

java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
guru.mikelue.foxglove.springframework.FoxgloveTestListener
All Implemented Interfaces:
Ordered, TestExecutionListener

public class FoxgloveTestListener extends AbstractTestExecutionListener
This listener resolving TableFacetsSource and DataGeneratorSource in Spring's Context framework of test first.

From Spring's context

  1. For named sources, using BeanFactory.getBean(String) to get object
  2. For subtype of TableFacetsProvider or DataGeneratorProvider, using BeanFactory.getBean(Class) to get object of that type.
  3. For DataGenerator, using BeanFactory.getBean(Class) with type of TableFacetsProvider.class, or DataGenerator.class.
    This method would throw NoUniqueBeanDefinitionException if there are multiple candidates in the context.
  4. For TableFacet, using BeanFactory.getBean(Class) with type of TableFacetsProvider.class.
    This method would throw NoUniqueBeanDefinitionException if there are multiple candidates in the context.

Auto-constructing default DataGenerator

If the Spring's context cannot find a viable DataGenerator bean, this listener will construct with:
  1. Using TestTransaction.isActive() and DataSourceUtils.getConnection(DataSource) to get current transaction's connection for data generation.
  2. Otherwise, using DataSource to construct a new DataGenerator(prototype scope).

Otherwise, this listener follows the semantics defined by annotation doc.

Nested test classes

This listener doesn't support resolving sources from enclosing classes.
However, you could use Spring's NestedTestConfiguration to resolve sources from Spring's context.

See Also: