Common Errors in SpringUnit Tests

Incorrect Name of SpringUnitContext Property in Java


A SpringUnit test fails because the name of the SpringUnitContext property of the test is incorrect in the Java source code.


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


This error occurs when the name of the SpringUnitContext property in the Java source code 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: private SpringUnitContext fooTest;


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

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

public class IncorrectPropertyNameInJavaTest extends SpringUnitTest {
    public void testWillFail() throws Exception {
    public SpringUnitContext getIncorectPropertyNameInJavaTest() {
        return incorectPropertyNameInJavaTest;

    public void setIncorectPropertyNameInJavaTest(
            SpringUnitContext incorectPropertyNameInJavaTest) {
        this.incorectPropertyNameInJavaTest = incorectPropertyNameInJavaTest;

    private SpringUnitContext incorectPropertyNameInJavaTest;

XML Configuration File:

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