Hey - I am starting to use the test framework that Spring provides instead of writing my own (which would be hackey...)
But I think that there is something I am fundamentally missing/screwing up.
What is happening is that I am setting a string field through Spring and it seems to not be 'sticking'. Meaning I see it come in (debugger) and then be set to the right value - then when the test runs it is null...here is the code:
springTest/SimpleTestSuite.java
springTest/SimpleTestSuite-context.xmlCode:package springTest; import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class SimpleTestSuite extends AbstractJUnit4SpringContextTests { private String testName = null; public void setTestName (String testName) { this.testName = testName; } @Test public void testSetName () throws Exception { assertNotNull (this.testName); } }
I know it is simple but it doesn't make sense to me. Oh and the assert fails, btw...Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="testSuite" class="springTest.SimpleTestSuite"> <property name="testName" value="somecrap"/> </bean> </beans>


Reply With Quote
