Skip to content

single executable jbang-based junit test class #756

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

Merged
merged 3 commits into from
May 20, 2021

Conversation

blafond
Copy link
Member

@blafond blafond commented May 13, 2021

targets issue #721

FIrst pass at a single junit test class that's executable by jbang CLI

@blafond blafond requested a review from DavideD May 13, 2021 21:14
@blafond blafond force-pushed the 721-jbang-executable-test branch from 61ae4c1 to b2719bd Compare May 14, 2021 03:11
@DavideD
Copy link
Member

DavideD commented May 14, 2021

Thanks @blafond!

It needs some minor improvements to the way it's documented but overall it looks good to me.
An alternative would be to create something closer to what we do for the examples.

I've created a quick POC here: https://github.com/DavideD/hibernate-reactive/blob/721-jbang-executable-test/tooling/jbang/Example.java

If you want to see them in action, here's how it works:

  1. Download JBang
  2. Start the default Postgres we use for testing (you can replace podman with docker):
    podman run --rm --name HibernateTestingPGSQL \
    -e POSTGRES_USER=hreact -e POSTGRES_PASSWORD=hreact -e POSTGRES_DB=hreact \
    -p 5432:5432 postgres:13.2
    
  3. JBang it:
    jbang https://github.com/DavideD/hibernate-reactive/blob/721-jbang-executable-test/tooling/jbang/Example.java
    
    or
    jbang https://github.com/blafond/hibernate-reactive/blob/721-jbang-executable-test/tooling/jbang/SampleIssueTest.java
    
  4. (Optional) If you want to edit the class with Idea
    jbang edit --open=idea https://github.com/blafond/hibernate-reactive/blob/721-jbang-executable-test/tooling/jbang/SampleIssueTest.java
    

Not sure which one I prefer. Maybe we can keep both? The JUnit one could be helpful to show how one can test Hibernate Reactive (maybe we can make it make it slightly more complex and add a couple of tests instead of only keep one) while the example one might be more familiar to the user and we can keep it simpler.

Note that I've asked @blafond to not create a template for now (because it makes it slightly harder to prototype with them). I think it makes sense to convert these classes to JBang templates ones we are happy with them and we can send a pr to JBang to add them to the catalogue.

@gavinking What do you think?
@gbadner, @Sanne In case you are interested and want to see an example of JBang in action

Cheers

@blafond blafond force-pushed the 721-jbang-executable-test branch from b2719bd to ac958c4 Compare May 19, 2021 14:04
Copy link
Member

@DavideD DavideD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,
looks pretty good.

We can play a bit more with this in the future, but I think this is a good starting point.
I will probably change a couple of minor things when working on the contribution guide.

In particular, I wouldn't keep a separate README for this. But we can change it later.

@DavideD DavideD merged commit c91dd01 into hibernate:main May 20, 2021
@DavideD DavideD linked an issue May 20, 2021 that may be closed by this pull request
@blafond blafond deleted the 721-jbang-executable-test branch May 20, 2021 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate how to create a template for JBang to help with bug reports
2 participants