Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot Test Fails with NoSuchBeanDefinitionException. #621

Closed
ecormaksin opened this issue Dec 24, 2018 · 8 comments
Closed

Spring Boot Test Fails with NoSuchBeanDefinitionException. #621

ecormaksin opened this issue Dec 24, 2018 · 8 comments

Comments

@ecormaksin
Copy link

Any advice would be appreciated.

[provide a description of the issue]

Environment
  • Operating System: macOS High Sierra 10.13.6
  • JDK version: 1.8.0_151
  • Visual Studio Code version: 1.30.1
  • Java extension version: 0.5.0
  • Java Debugger extension version: 0.16.0
Steps To Reproduce
  1. Create Spring Boot project by following the page below. https://code.visualstudio.com/docs/java/java-spring-boot
  2. Write test code with annotations below.
    @RunWith(SpringRunner.class)
    @SpringBootTest
    @ContextConfiguration(classes = BatchTestConfig.class)
  3. Run the test.

[attach a sample project reproducing the error]
2018-12-24_TestReport.log

Current Result

NoSuchBeanDefinitionException occurs. But the test finishes with green on the Eclipse IDE.

Expected Result

The test finishes with green(passed).

Additional Informations
@testforstephen
Copy link
Contributor

@jdneo could you help a look?

@jdneo
Copy link
Member

jdneo commented Feb 14, 2019

@ecormaksin May I ask how do you trigger the test?

@ecormaksin
Copy link
Author

ecormaksin commented Feb 17, 2019

@jdneo Thanks for your reply.

I trigger the test by clicking 「Run Test」link on VS Code Editor.

I uploaded the repository as pubic.
https://github.com/ecormaksin/BatchTaskletApplication-1

Could you check if you possible?

The target test is "com.tasklet.batch.service.test.PrintServiceTest";

@ecormaksin
Copy link
Author

launch.json is below.

{ "configurations": [ { "type": "java", "name": "CodeLens (Launch) - BatchTaskletApplication", "request": "launch", "mainClass": "com.tasklet.batch.BatchTaskletApplication", "projectName": "BatchTaskletApplication-1" } ] }

And java.test.config is below.

{ "java.test.config": [ { "name": "BatchTaskletApplication-1", "workingDirectory": "<projectrootpath>", "args": [], "vmargs": [], "env": {} } ] }

@testforstephen testforstephen transferred this issue from microsoft/vscode-java-debug Feb 18, 2019
@jdneo
Copy link
Member

jdneo commented Feb 25, 2019

Hi @ecormaksin,

Thank you for reporting the issue and give us the sample project. After some investigation, I think I might find out the root cause.

The root cause is that when the extension running the tests, it will read the application.properties under the target folder. But the content of it is the same as that in the src (not the one in test). After I copied the application.properties in the test to the target folder, the test cases can be run successfully.

This issue might be related to #534

I'll think about how to make a fix and let you know.

Thank you.

@jdneo
Copy link
Member

jdneo commented Feb 25, 2019

More investigation result here: #534 (comment)

@jdneo
Copy link
Member

jdneo commented Feb 26, 2019

Closing this issue and let's track it in #534

@ecormaksin
Copy link
Author

I apoligize for too late reply. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants