0
在我的项目中,我编写了一个存储库类,以便我需要编写内存中的测试类。我的存储库代码如下。Spring数据jpa知识库内存中测试用例
package org.jaap.reference.repository;
import java.util.List;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.stereotype.Repository;
import org.jaap.entity.AccountType;
/**
* Repository for type
*
*/
@Repository
public interface AccountTypeRepository
extends JpaRepository<AccountType, Integer>, QueryDslPredicateExecutor<Type> {
/**
* @param AccountTypeCode
* @return List<Type>
*/
@Query("select T from AccountType T where T.AccountTypeCode not in ?# {@environment.getProperty('commit.types').split(',')}")
List<AccountType> findByAccountTypeCodeNotIn();
}
为此我需要使用junit编写单元测试用例,mockito任何人都可以帮助我吗?
喜,没有帮助...'addressService'为空...自动布线对我来说不起作用..我做错了什么? – Sergey
@georges van我问In-Memory测试,在数据库中插入数据,这些数据用于内存和测试用例。 – AdamIJK
@Sergey不使用Autowired for Service类,只声明服务类并运行测试用例,希望它能为你工作。 – AdamIJK