java - How can I use the Parameterized JUnit test runner with a field that's injected using Spring? -


I am using Spring to inject a path to a directory in my unit tests. There are several such files inside this directory that should be used to create test data for a test case with parameters using a test runner. Unfortunately, the test runner requires that the method providing the parameters is fixed. This does not work for my situation because the directory can only be injected into a non-stationary area. Any ideas how can I get around this?

I think you are using the juneit 4.x because you have mentioned the parametric test Runner means that you are not using @RunWith (SpringJUnit4ClassRunner). No problem, just list my beliefs.

The following uses the spring to get the test file directory from the XML file. It does not inject, but the data is still available for your testing. And not less in a steady method.

I see that the only disadvantage is that it can mean that your spring configuration is being parsed / configured multiple times, you can load only a small file with specific information about the exam If needed.

  @RunWith (paramized.class) Public class mitest {@Parameters Public static collection & lt; Object [] & gt; Data () {ApplicationContext ctx = New classpath XmlApplicationContext ("/ jeanne / jeanne.xml"); String Dior = CTX Gatebin ("TestFile Directory", string class); // to write Java code to array files in the test directory on array returns Arrays.asList (new object [] [] {{}}); } // the rest of the test class}}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -