Announcement Announcement Module
Collapse
No announcement yet.
spring 3.2 junit 4.x as system test runner Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring 3.2 junit 4.x as system test runner

    I am porting an old system from junit 3.8 to spring 3.2 + junit 4.x.

    This system contains a set of system tests (in addition to standard unit tests).

    The system test involves several applications in several processes. These other processes process data after it is comited by the main application being tested.

    The database is reloaded be the function decorated with the @BeforeTransaction annotation. This allows for each system test to run in a db of a "known" state.

    Each PreTest setup involves:
    1) reset and rebuild db for test
    2) start external processes that read data committed by application being tested


    System Test Requirements

    1) full spring transactional behavior is required. These test are system tests ran by junit, not a unit test ran by junit. The system test launched by junit must have the same transaction semantics as production code. Other then the database name, the application context definitions for tests and production are identical. We use a test profile to load different db names for test and production.

    We would like for junit to create a transaction for the test case, and let the preTest setup run in a transaction managed by junit and have all transactions in the application code commit to the database (just like it does in production).

    Class Level annotations(per test class)
    @RunsWith(SpringJUnit4ClassRunner.class)
    @TransactionConfiguration(defaultRollback=true)
    @Transactional
    @ContextConfiguration(locations="/META-INF/spring/applicationContext.xml")
    @ActiveProfiles(profiles="test")



    Test Function level annotations
    @Rollback(false)


    @BeforeTransaction is used on the function that clears and loads the db
    @Rollback(false) is added to the init function (not sure if this is needed)




    Are the the correct options to use junit 4.x to execute system tests in spring.

    Thanks,
    Mike
    Last edited by scmikes; Feb 25th, 2013, 12:05 AM. Reason: clarifacation
Working...
X