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

Not working well in spring boot junit test #76

Closed
danielludan opened this issue Jan 3, 2018 · 4 comments
Closed

Not working well in spring boot junit test #76

danielludan opened this issue Jan 3, 2018 · 4 comments
Labels

Comments

@danielludan
Copy link

It seems the spring boot context can't read configuration properly when running case, the test case src structure is followed maven default standard. The case can be executed on Eclipse IDE so it can't be case issue. Not sure if there is someway to config resource in test running to solve the issue. Thanks for your attention.

@ansyral
Copy link
Collaborator

ansyral commented Jan 5, 2018

@danielludan could you help share a sample about it? Thanks.

@jQwotos
Copy link

jQwotos commented Jul 25, 2018

Having the same problem.
Trying to run spring boot controller tests without any avail.
Works in IntelliJ

Tests are decorated with

@RunWith(SpringRunner.class)
@SpringBootTest

(RunWith from Junit)
Tests all extend junit Assert

Output

Error occurred: line 562:213 token recognition error at: '+'
line 562:215 token recognition error at: '�'
line 562:216 token recognition error at: '�'
line 562:217 token recognition error at: '�'
line 562:218 token recognition error at: '�'
line 562:219 token recognition error at: '�'
line 562:220 token recognition error at: '�'
line 562:221 token recognition error at: '�'
line 562:222 token recognition error at: '�'
line 562:223 token recognition error at: '�'
line 562:224 token recognition error at: '�'
line 562:225 token recognition error at: '�'
line 562:226 token recognition error at: '�'
line 562:227 token recognition error at: '�'
line 562:228 token recognition error at: '�'
line 562:229 token recognition error at: '�'
line 562:230 token recognition error at: '�'
line 563:0 token recognition error at: '�'
line 563:1 token recognition error at: '�'
line 563:2 token recognition error at: '�'
line 563:3 token recognition error at: '�'
line 563:4 token recognition error at: '�'
line 563:5 token recognition error at: '''
Failed to run tests.

@callain
Copy link

callain commented Sep 18, 2018

Here is an example of application.properties under src/test/resources which I believe is either not being load or not filtered when I click on Run Test.

There is maven properties filtering in it. And those properties are in a profile active by default.

# DATASOURCE
# Note that those properties should be define in your maven settings and are profile dependent
spring.datasource.type = com.zaxxer.hikari.HikariDataSource
spring.datasource.url = ${test.database.url}
spring.datasource.username = ${test.database.username}
spring.datasource.password = ${test.database.password}
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: java.lang.NullPointerException
	at liquibase.changelog.StandardChangeLogHistoryService.init(StandardChangeLogHistoryService.java:120)

Test runs fine if I launch it with maven command line.

Here is launch.test.json

{
    "run": {
        "default": "",
        "items": [
            {
                "name": "my-project",
                "projectName": "my-project",
                "workingDirectory": "/path/to/my-project",
                "args": [],
                "vmargs": [],
                "env": {},
                "preLaunchTask": ""
            }
        ]
    }
}

I don't know if I need to configure something or how to do it

@jdneo jdneo added the bug label Nov 9, 2018
@jdneo
Copy link
Member

jdneo commented Jan 3, 2019

There is a workaround here: #534 (comment)

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

@jdneo jdneo closed this as completed Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants