問題タブ [spring-boot-test]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
2 に答える
1899 参照

spring-boot - HSQL なしで JPA を使用して Spring ブート テスト ランナーを実行できない

AbstractRoutingDataSource、Mockito を使用して、Spring ブートで MyBatis と JPA の両方で動作するアプリケーションのテスト ケースを作成しようとしています。mybatis コードをモックできます。JPA を統合すると、@SpringBootTest が失敗している AbstractRoutingDataSource データソースにアクセスしようとします。

私たちはmockitoを最大限に使用したいので、テストにHSQL/H2データベースを使用したくないため、必要なすべてのデータを挿入するためにコードが増加します。以下のエラーログを見つけてください。

AbstractRoutingDataSource をモックしようとしましたが、それでも別のエラーがスローされます。

0 投票する
3 に答える
4500 参照

spring - @DataMongoTest は null の MongoTemplate を作成しています

以下のリンクの指示に従って、Cucumber 統合テスト用に自動的に構成された組み込み MongoDB インスタンスを追加しようとしています。null の MongoTemplate を取得し続けるため、これは現在機能していません。@DataMongoTest は「@Autowired private MongoTemplate mongoTemplate;」を自動的に構成すると思いました。そうではありませんか?以下は私のコードです:

mongoTemplate.save(ドキュメント、コレクション); nullpointer 例外をスローします。

pom.xml ファイル:

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-autoconfigured-mongo-test

0 投票する
1 に答える
1475 参照

spring-boot - Spring Boot Test を使用してカスタム リポジトリをテストできない

Spring Boot 1.4.4 を使用しています。単体テストについては、Spring Boot Testの記事に従いました。カスタム リポジトリがある場合、テストが機能せず、エラーで失敗しますUnsatisfiedDependencyException: Error creating bean with name 'com.jay.UserRepositoryTest': Unsatisfied dependency expressed through field 'userRepository';

ここに私のコードがあります、

しかし、構成を変更せずに、Spring Boot で次の Dao をテストできます。

を使用しているときは@SpringBootTest、注入できますがUserRepository、できませんTestEntityManager