You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Niels Basjes <Ni...@basjes.nl> on 2021/05/06 09:30:04 UTC

Testing for valid missing "provided" dependencies.

Hi,

I have written a java library that I want to be fully working for various
situations.

The thing I'm having trouble with is testing my error handling in case of
missing dependencies that are expected to be "provided".
Some of these dependencies are only called in edge cases in the processing.
Thus I have a forced check at the startup to verify everything is correct.

I have created several maven modules in my project dedicated to those kinds
of tests.

I found however that in some cases it makes a difference running the "mvn
test" in those modules when running them from the root of the project or
when running it only in the specific testing module.

Specific example:
I have log4j-core as a provided dependency in my "library" module and when
I run the "full project" build my error handling test fails as the testing
module will "have" the log4j-core dependency (where I want to test the
scenario it doesn't have it).
So my build fails.

I then continue the build with    mvn package -rf
:integration-tests-logging-java-no-log4j
then the test does pass (i.e. the missing dependency is properly missing
and the error handling works as expected).

What is the correct way to resolve this effect?

-- 
Best regards / Met vriendelijke groeten,

Niels Basjes

Re: Testing for valid missing "provided" dependencies.

Posted by Niels Basjes <Ni...@basjes.nl>.
Cool,

I'll create a minimal reproduction.

Niels

On Thu, May 6, 2021 at 11:35 AM Tamás Cservenák <ta...@cservenak.net> wrote:

> Howdy,
>
> could you create a simple resproducer for this? As for me, it is unclear:
> - what "my library module" is
> - what is "integration-tests-logging-java-no-log4j" is (is it same as
> above? from name, seems not)
> - if the two not same, are the integration test having same dependences as
> "library" (I mean, in one log4j is present in other is not)
> - I think these are two distinct modules but you mention "same test"
> passing and failing?
>
> IMO, a reproducer would immediately explain the issue (and may be base for
> a possible IT as well)...
>
> Thanks in advance
> T
>
> On Thu, May 6, 2021 at 11:30 AM Niels Basjes <Ni...@basjes.nl> wrote:
>
> > Hi,
> >
> > I have written a java library that I want to be fully working for various
> > situations.
> >
> > The thing I'm having trouble with is testing my error handling in case of
> > missing dependencies that are expected to be "provided".
> > Some of these dependencies are only called in edge cases in the
> processing.
> > Thus I have a forced check at the startup to verify everything is
> correct.
> >
> > I have created several maven modules in my project dedicated to those
> kinds
> > of tests.
> >
> > I found however that in some cases it makes a difference running the "mvn
> > test" in those modules when running them from the root of the project or
> > when running it only in the specific testing module.
> >
> > Specific example:
> > I have log4j-core as a provided dependency in my "library" module and
> when
> > I run the "full project" build my error handling test fails as the
> testing
> > module will "have" the log4j-core dependency (where I want to test the
> > scenario it doesn't have it).
> > So my build fails.
> >
> > I then continue the build with    mvn package -rf
> > :integration-tests-logging-java-no-log4j
> > then the test does pass (i.e. the missing dependency is properly missing
> > and the error handling works as expected).
> >
> > What is the correct way to resolve this effect?
> >
> > --
> > Best regards / Met vriendelijke groeten,
> >
> > Niels Basjes
> >
>


-- 
Best regards / Met vriendelijke groeten,

Niels Basjes

Re: Testing for valid missing "provided" dependencies.

Posted by Tamás Cservenák <ta...@cservenak.net>.
Howdy,

could you create a simple resproducer for this? As for me, it is unclear:
- what "my library module" is
- what is "integration-tests-logging-java-no-log4j" is (is it same as
above? from name, seems not)
- if the two not same, are the integration test having same dependences as
"library" (I mean, in one log4j is present in other is not)
- I think these are two distinct modules but you mention "same test"
passing and failing?

IMO, a reproducer would immediately explain the issue (and may be base for
a possible IT as well)...

Thanks in advance
T

On Thu, May 6, 2021 at 11:30 AM Niels Basjes <Ni...@basjes.nl> wrote:

> Hi,
>
> I have written a java library that I want to be fully working for various
> situations.
>
> The thing I'm having trouble with is testing my error handling in case of
> missing dependencies that are expected to be "provided".
> Some of these dependencies are only called in edge cases in the processing.
> Thus I have a forced check at the startup to verify everything is correct.
>
> I have created several maven modules in my project dedicated to those kinds
> of tests.
>
> I found however that in some cases it makes a difference running the "mvn
> test" in those modules when running them from the root of the project or
> when running it only in the specific testing module.
>
> Specific example:
> I have log4j-core as a provided dependency in my "library" module and when
> I run the "full project" build my error handling test fails as the testing
> module will "have" the log4j-core dependency (where I want to test the
> scenario it doesn't have it).
> So my build fails.
>
> I then continue the build with    mvn package -rf
> :integration-tests-logging-java-no-log4j
> then the test does pass (i.e. the missing dependency is properly missing
> and the error handling works as expected).
>
> What is the correct way to resolve this effect?
>
> --
> Best regards / Met vriendelijke groeten,
>
> Niels Basjes
>