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

Add @JooqTest support #9343

Closed
wants to merge 6 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@michael-simons
Contributor

michael-simons commented May 29, 2017

This PR introduces the @JooqTest annotation.

See #8544.

If you think those slices are getting out of hand and this PR is closed, I'd understand it, but the annotation would be very useful as you meaningful testing of jOOQ generated queries is only possible in integration scenarios. I'd even thought if it would be a good idea not replacing the default database with that one here.

@snicoll snicoll self-assigned this May 31, 2017

@snicoll snicoll added this to the 2.0.0.M2 milestone May 31, 2017

@snicoll

@michael-simons I have one more question.

* By default, tests annotated with {@code @JooqTest} will use an embedded in-memory
* database (replacing any explicit or usually auto-configured DataSource). Since
* jOOQ relies heavily on a Java-based schema that corresponds with the database schema,
* that is propably not what you want. The

This comment has been minimized.

@snicoll

snicoll May 31, 2017

Member

I am confused. Why is the default behaviour of the annotation not what the use wants? The purpose of a slice annotation is to do the right thing by default!

@snicoll

snicoll May 31, 2017

Member

I am confused. Why is the default behaviour of the annotation not what the use wants? The purpose of a slice annotation is to do the right thing by default!

This comment has been minimized.

@michael-simons

michael-simons May 31, 2017

Contributor

jOOQ depends heavily on the fact that the current database scheme is in sync with the generated Java based scheme. Otherwise queries derived from jOOQ generated classes will break.
I assumed that you would favor this PR more if @JooqTest would behave like the other slices related to databases.
I am using something like @JooqTest without embedded database right now and would turn it off in most cases.

If it's ok with the slice doing that thing different than the other databases slices, super fine with me.

@michael-simons

michael-simons May 31, 2017

Contributor

jOOQ depends heavily on the fact that the current database scheme is in sync with the generated Java based scheme. Otherwise queries derived from jOOQ generated classes will break.
I assumed that you would favor this PR more if @JooqTest would behave like the other slices related to databases.
I am using something like @JooqTest without embedded database right now and would turn it off in most cases.

If it's ok with the slice doing that thing different than the other databases slices, super fine with me.

This comment has been minimized.

@snicoll

snicoll May 31, 2017

Member

Of course it is ok. The purpose of a dedicated slice annotation is that it's doing a dedicated job for the task at hand. I've merged your PR with that modification, please review the polish commit. Thanks!

@snicoll

snicoll May 31, 2017

Member

Of course it is ok. The purpose of a dedicated slice annotation is that it's doing a dedicated job for the task at hand. I've merged your PR with that modification, please review the polish commit. Thanks!

snicoll added a commit that referenced this pull request May 31, 2017

Add @JooqTest
This commit provides test slicing for jOOQ.

See gh-9343

@snicoll snicoll closed this in d096dca May 31, 2017

snicoll added a commit that referenced this pull request May 31, 2017

Merge pull request #9343 from michael-simons:jooqTest
* pr/9343:
  Polish "Add @JooqTest"
  Add @JooqTest
@michael-simons

This comment has been minimized.

Show comment
Hide comment
@michael-simons

michael-simons May 31, 2017

Contributor

Thanks. Works as expected. I've already updated @lukaseder's example in my branch michael-simons/jOOQ@120ad7f.

I'd personally recommend a test approach with @JooqTest and using the auto configured DSLContext to instantiate the services that uses it manually. Having the queries hard coded in the test as shown in the example doesn't make much sense apart from showing how stuff works.

Edit: I actually have an example in Spring Boot Buch that's much nicer now: springbootbuch/database_examples@6dd64fe

Contributor

michael-simons commented May 31, 2017

Thanks. Works as expected. I've already updated @lukaseder's example in my branch michael-simons/jOOQ@120ad7f.

I'd personally recommend a test approach with @JooqTest and using the auto configured DSLContext to instantiate the services that uses it manually. Having the queries hard coded in the test as shown in the example doesn't make much sense apart from showing how stuff works.

Edit: I actually have an example in Spring Boot Buch that's much nicer now: springbootbuch/database_examples@6dd64fe

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