質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Groovy

Groovyは、Java用のオブジェクト指向型プログラミング言語です。PythonやRuby、Perl、そしてSmalltalkに似た特徴を有する動的な言語です。

JUnit

JUnitは、Javaで開発されたプログラムのユニットテストを行うためのアプリケーションフレームワークです。簡単にプログラムのユニットテストを自動化することができ、結果もわかりやすく表示されるため効率的に開発時間を短縮できます。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

IntelliJ IDEA

IntelliJ IDEA(インテリジェイ アイディア)は、JetBrains社が開発した、 JavaやScalaなどで利用される統合開発環境です。

Q&A

解決済

1回答

858閲覧

intelliJでテストコードを実行すると必ず失敗し、flywayやmigrationに問題があると言われる

kyrieCo

総合スコア11

Groovy

Groovyは、Java用のオブジェクト指向型プログラミング言語です。PythonやRuby、Perl、そしてSmalltalkに似た特徴を有する動的な言語です。

JUnit

JUnitは、Javaで開発されたプログラムのユニットテストを行うためのアプリケーションフレームワークです。簡単にプログラムのユニットテストを自動化することができ、結果もわかりやすく表示されるため効率的に開発時間を短縮できます。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

IntelliJ IDEA

IntelliJ IDEA(インテリジェイ アイディア)は、JetBrains社が開発した、 JavaやScalaなどで利用される統合開発環境です。

0グッド

1クリップ

投稿2022/06/03 16:00

実行環境はWindows10です。テスト対象はSpring Franeworkで記述されているJavaコードです
DBサーバーはDockerを通じて立ち上げています。
しかし、いざテストコードを実行すると、毎回以下のエラーが出てしまいます。

java

1java.lang.IllegalStateException: Failed to load ApplicationContext 2 3 at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132) 4 at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124) 5 at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118) 6 at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) 7 at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43) 8 at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244) 9 at org.spockframework.spring.SpringTestContextManager.prepareTestInstance(SpringTestContextManager.java:56) 10 at org.spockframework.spring.SpringInterceptor.interceptInitializerMethod(SpringInterceptor.java:46) 11 at org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:24) 12 at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:101) 13 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111) 14 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 15 at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111) 16 at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79) 17 at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) 18 at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:212) 19 at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:192) 20 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) 21 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 22 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) 23 at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:148) 24 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) 25 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 26 at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) 27 at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) 28 at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) 29 at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) 30 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) 31 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 32 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) 33 at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:148) 34 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) 35 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 36 at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) 37 at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) 38 at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) 39 at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) 40 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) 41 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 42 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) 43 at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) 44 at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) 45 at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) 46 at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) 47 at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) 48 at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) 49 at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) 50 at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) 51 at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) 52 at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) 53 at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) 54 at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) 55 at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) 56 at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) 57 at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) 58 at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) 59 at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) 60 at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) 61 at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) 62 at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) 63 at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) 64Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Unsatisfied dependency expressed through method 'flywayInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingException: Cannot find migration scripts in: [classpath:db/migration] (please add migration scripts or check your Flyway configuration) 65

エラー文で検索してもいまいち解決策がわからず、知り合いにたずねても見たことないエラーだと言われてしまい、大変困惑しております。

どなたかわかる方がいれば、教えていただきたいです

テストコードなどは諸事情により記載できないです。。ただ、どのテストコードを実行しても毎回同じエラーが出てテストが失敗してしまいます

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

YT0014

2022/06/04 00:18

エラーメッセージを最後までお読みになられましたか? 念のため、最後の部分を記載します。 FlywayMigrationScriptMissingException: Cannot find migration scripts in: [classpath:db/migration] (please add migration scripts or check your Flyway configuration)
kyrieCo

2022/07/01 04:02

返信が遅れてしまい大変申し訳ありません エラーメッセージは読みました。 また、原因はわからなったのですが、エラー自体は解決済みとなっております
guest

回答1

0

自己解決

ビルド高速化のため、intelliJのビルドの設定を変更していたことによって同エラーとなっていました。
(以下高速化設定画像)
イメージ説明
イメージ説明
イメージ説明
そのため、以下2つのどちらかを行うとエラーが出ずテストが実行できます

  • 設定をデフォルトに戻す
  • 設定を変更した場合、プロジェクト自体の再ビルドを行う。この場合、DBの環境を変更したりした後は同様のエラーがでたりするので、その度に再ビルドが必要

曖昧な理解ですので、根本的な原因についてご存じの方がいればご教示いただきたいです

投稿2022/07/01 04:12

kyrieCo

総合スコア11

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問