pessoal estou com um pequeno problema aqui na hora de testar meus beans com o spring. Testes com o junit, spring batch, app desktop.
eu tenho meus beans com o spring, tudo funcionando normalmente, estou tentando criar os testes para estes beans mas não está dando certo, primeira vez com ambos. No meu teste eu estou debugando e o objeto do bean do meu test case está sendo preenchido na minha suite, mas ele não é executado e está aparecendo uma exceção junit.framework.AssertionFailedError na aba do junit do eclipse.
Resumindo, o que eu estou fazendo de errado?
minha estrutura está deste jeito:
classe teste:
public class ClasseBeanTest extends TestCase{
private ClasseBean teste;
/**
* @param teste the teste to set
*/
public void setTeste(ClasseBean teste) {
this.teste = teste;
}
/**
* testa o método ConverterParaNegativacao com parametro pf
*/
public void testMetodoXXX() {
teste.metodoXXX();
}
}
meu teste suite:
package com.porto.negativacaoreabilitacao.test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class AllTests {
private static ClassPathXmlApplicationContext ctx;
public static Test suite() {
ctx = new ClassPathXmlApplicationContext(
"classpath:/config/applicationResources.xml");
TestSuite suite = new TestSuite();
suite.addTest(getBean("beanTest"));
// suite.addTest(getBean(""));
// suite.addTest(getBean(""));
return suite;
}
public static TestCase getBean(String nome){
TestCase t = (TestCase)ctx.getBean(nome);
return t;
}
}
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean id="beanTest" class="pacote.ClasseBeanTest">
<property name="teste" ref="bean"/>
</bean>
<bean id="bean" class="pacote.ClasseBean">
</bean>