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 with static variable #98

Closed
naviud opened this issue Jul 10, 2024 · 2 comments
Closed

Not working with static variable #98

naviud opened this issue Jul 10, 2024 · 2 comments

Comments

@naviud
Copy link

naviud commented Jul 10, 2024

Describe the bug
As mentioned in README, I tried to create a private static LogCaptor variable and initialized from a method annotated with @BeforeAll. So the method should be a static ofc. With that approach, looks like logs are not captured.

But this works perfectly with non static way.

To Reproduce

  1. Simply follow the readme -> https://github.com/Hakky54/log-captor?tab=readme-ov-file#initialize-logcaptor-once-and-reuse-it-during-multiple-tests-with-clearlogs-method-within-the-aftereach-method

Expected behavior
Way mentioned above is the elegant way. I believe, it should work in that way as well.

Environmental Data:

  • Java Version 17.0.10
  • Maven Version 3.9.7
  • OS (Windows/Linux/MacOS) MacOS(M1)

Additional context
N/A

@Hakky54
Copy link
Owner

Hakky54 commented Jul 10, 2024

Hi @naviud thank you creating this ticket and nice to see that developers actually are giving the examples a try. That example should work, so I find it strange that it is not working for you. I added a test case which is exactly running the example which you mentioned, see here: #99

And it is passing. So it is probably not related to logcapture, but maybe to something else...
Is your Junit 5 dependency correctly defined? Or are you using something else to have a similar structure?

Maybe you can create a small POC repository at your github profile, so we can have a look at it together, what do you think?

@Hakky54
Copy link
Owner

Hakky54 commented Jul 15, 2024

I am closing this ticket as the issue you mentioned is not happening as shown here: #99

The tests are passing with the setup you mentioned. So I am assuming it is related to your local dev environment or ide setup. If you still have the issue, I am willing to help you out. You can create a private repo at github and add me as collaborator which will give the the possibility to invesitgate and test it on my side

@Hakky54 Hakky54 closed this as completed Jul 15, 2024
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 a pull request may close this issue.

2 participants