gi_dor

TDD-[Spring]java.lang.Exception: No runnable methods , java.lang.NullPointerException 본문

First/Error

TDD-[Spring]java.lang.Exception: No runnable methods , java.lang.NullPointerException

기돌 2023. 5. 18. 15:51
5월 18, 2023 3:37:52 오후 org.junit.vintage.engine.descriptor.RunnerTestDescriptor warnAboutUnfilterableRunner
WARNING: Runner org.junit.internal.runners.ErrorReportingRunner (used on class com.fastcampus.ch2.UserDaoImplTest) does not support filtering and will therefore be run completely.

java.lang.Exception: No runnable methods
java.lang.NullPointerException

에러 발생  : runnable 에다가 Nullpoint Exception 이요 ????? 예?

 


package com.fastcampus.ch2;


import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.sql.DataSource;
import java.util.Date;
import java.util.List;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

@RunWith(SpringJUnit4ClassRunner.class) // ApplicationContext ac 자동으로 만들어줌 ,  에러시 spring test 라이브러리 있나 한번보셈
@ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/spring/**/root-context.xml"}) // root.xml. 설정파일 위치 지정
public class UserDaoImplTest {
    @Autowired
    UserDao userdao;

// userDao 인터페이스 구현한곳에서  인스턴스들 받아먹으려고
// userDao 객체도 안만들고 넘겨받아서 메서드나 인스턴스 사용할수있음

    @Test
    public void insertUser() throws Exception {
        userdao.deleteAll();
        User user = new User("TestHanReal", "1234", "ABC", "aaa@Aaaa.com", new Date(), "fb", new Date());

        int rowCnt = userdao.insertUser(user);

        //   User user2 = userdao.selectUser("TestHanReal");
        assertTrue(rowCnt == 1);
    }

 

root-context.xml 확인 해봐도 잘되있는거 같음

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
			 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			 xmlns="http://www.springframework.org/schema/beans"
			 xmlns:context="http://www.springframework.org/schema/context"
			 xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
	<!-- Root Context: defines shared resources visible to all other web components -->


	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
		<property name="url" value="jdbc:mysql://localhost:3306/springbasic?useUnicode=true&amp;characterEncoding=utf8"></property>
		<property name="username" value="Han"></property>
		<property name="password" value="1234"></property>
	</bean>


	<context:component-scan base-package="com.fastcampus.ch2">
		<context:exclude-filter type="regex" expression="com.fastcampus.ch2.diCopy*.*"/>
	</context:component-scan>



</beans>

원인:

 

 


 

 

 

 

728x90