Common Errors in SpringUnit Tests

Incorrect Name of SpringUnitContext Property in XML Configuration File


A SpringUnit test fails because the name of the SpringUnitContext property of the test is incorrect in the XML configuration file.


        Error creating bean with name 'org.springunit.examples.errors.IncorrectPropertyNameInXmlTest':
        Unsatisfied dependency expressed through bean property 'incorrectPropertyNameInXml':
        Set this property value or disable dependency checking for this bean.


This error occurs when the name of the SpringUnitContext property in the XML configuration file does not conform to the SpringUnit convention.


Ensure the name of the property is classname where classname is equivalent to the simple name of the Java test class. For example, if your test class is, then the property should be declared this way: <bean id="fooTest" class="org.springunit.framework.SpringUnitContext">


Java Source Code:
package org.springunit.examples.errors;

import org.springunit.framework.SpringUnitContext;
import org.springunit.framework.SpringUnitTest;

public class IncorrectPropertyNameInXmlTest extends SpringUnitTest {
    public void testWillFail() throws Exception {
    public SpringUnitContext getIncorrectPropertyNameInXml() {
        return incorrectPropertyNameInXml;

    public void setIncorrectPropertyNameInXml(
            SpringUnitContext incorrectPropertyNameInXml) {
        this.incorrectPropertyNameInXml = incorrectPropertyNameInXml;

    private SpringUnitContext incorrectPropertyNameInXml;

XML Configuration File:

    <bean id="incorectPropertyNameInJavaTest" class="org.springunit.framework.SpringUnitContext">
        <property name="data">
            	<! -- Test data goes here -->
Previous Next