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