I have a question about configuring Junit Test Suite. First of all, I am using JUnit libarary version 4.7.
My problem is to create the application context in the test suite and then allow access to the entire running test suite for the application context. I need the application context because some unit test uses it to fill in the required data. Therefore, I reuse the class to do things.
The following is my snipplet:
@RunWith(Suite.class) @SuiteClasses({RestServiceUnitTest.class}) public class IntegrationSuite { public ApplicationContext appCtx; @BeforeClass public static void setUp() { System.out.println("setting up in Suite"); appCtx = new FileSystemXmlApplicationContext("/integrationtest/rest_test_app_ctx.xml" ); } @AfterClass public static void tearDown() { System.out.println("tearing down in Suite"); CleanUp cleaner = (CleanUp)appCtx.getBean("cleanup"); cleaner.clean(); } }
I need appCtx to be available for the RestServiceUnitTest class. Can I find out how to do this? Anyone has an idea.
I think this is very similar: Call Testing: How to set up sharing of all test suites
But I'm not sure how to access the variable you created in the testsuite class in unittest, as the answer does not mention it.
source share