🧐 🤔 그거 어떻게 쓰더라 🙄 😙

스프링부트 Run as JUnit Test 아무 일도 일어나지 않음 (에러가 뜨는 것도 아님)

2023. 6. 2. Evergood Kim이가 씀

Run as JUnit Test 아무 일도 일어나지 않음 (에러가 뜨는 것도 아님)

Spring Boot test라거나 JUint Test라고 검색해도 다들 테스트 케이스 추가해서 잘만 테스트 함.

의존성 추가 문제 아님.

그리고 자바 파일 우클릭 > New > JUnit Test Case으로 테스트 케이스를 추가하면 검색결과에서는 다들 test 폴더 하위에 새 파일이 생성되는데 나는 같은 폴더에 생기는 것도 이유를 모르겠음.

얘가 아예 테스트 코드가 없다는 듯이 나오는 게 이상해서 Build Path에 src/test/java 추가해봄

org.springframework.boot.test cannot be resolved 에러 뜸.

해당 에러를 검색했더니 pom.xml에서 해당 의존성에 <scope>test</scope>를 삭제하라고 함.

그런데 테스트에 쓰는 게 맞는데 저걸 없앤다는 건 아무래도 이상하고, 테스트가 잘 되는 다른 더미 프로젝트에서도 보면 <scope>test</scope>가 있는데도 단위 테스트가 잘만 실행되는 걸 보고 이건 적절한 해결책이 아니라고 생각함.

결국; src/test/java 폴더를 build path에 추가 후, 다른 설정 했더니 되는데.

저거 설정하면 프로젝트 루트 경로의 .classpath 파일이 변경되더라.

근데 프로젝트를 원격 깃에서 새로 받아서 import 해보니까 애초부터 저렇게 설정돼있는데. 저 놈은 왜 그랬는지 몰라.

구글링해도 안 나올 만큼 아무도 겪지 않는 일 때문에 개삽질했네.

mine
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="target/classes" path="src/main/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="optional" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
		<attributes>
			<attribute name="module" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" path="target/generated-sources/annotations">
		<attributes>
			<attribute name="ignore_optional_problems" value="true"/>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="m2e-apt" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
		<attributes>
			<attribute name="ignore_optional_problems" value="true"/>
			<attribute name="test" value="true"/>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="m2e-apt" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>
728x90