You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ron Wheeler <rw...@artifact-software.com> on 2013/10/28 00:22:09 UTC

Best Practice for testing code that uses provided dependencies

We have code that depends on "provided" libraries.

What is the best way to test the code?

I don't particularly want to add the shared libraries to the project 
since they are large and will add a big load into the SCM and make it 
hard to check out the project.

Can I add the dependency twice, once as provided and once as test?
Any comments or suggestions?

Ron

-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Best Practice for testing code that uses provided dependencies

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 27/10/2013 10:36 PM, Russell Gold wrote:
>
> On Oct 27, 2013, at 9:38 PM, Ron Wheeler 
> <rwheeler@artifact-software.com 
> <ma...@artifact-software.com>> wrote:
>
>> On 27/10/2013 7:59 PM, Russell Gold wrote:
>>> I’m actually running into the same issue, and my plan was s to take 
>>> advantage of the situation to provide test versions of the classes. 
>>> What I found was that the “provided” dependency wound up in the test 
>>> class path.
>>>
>>> So I think that the fact that it is provided should have no impact 
>>> on how you test it.
>> I am not sure what you mean.
>> If scope is provided, does that mean that you have to add the jar to 
>> the project?
>> Or does "provided" turn out to be like compile when the tests are run?
>
> Yes; if scope is “provided”, maven will make sure the jar is available 
> on the compile class path as well as the test compile and test run 
> class paths; however, anything that depends on your module will not 
> inherit the dependency transitively, I believe (although I have tried 
> this) that if you use an assembly plugin to package your project, it 
> will ignore the provided dependency. I’m not sure what you mean by 
> “add the jar to the project.”

Some developers have added a lib directory to the project and added the 
"provided" jars to that folder and made that part of the library set in 
the build path.

>
>>
>> I guess that Eclipse does not understand that. It can not resolve the 
>> imports. Not really a maven problem
>
> It seems to work in IntellijIDEA, though.
>
>>
>>>
>>> - Russ
>>>
>>> On Oct 27, 2013, at 7:22 PM, Ron Wheeler 
>>> <rwheeler@artifact-software.com 
>>> <ma...@artifact-software.com>> wrote:
>>>
>>>> We have code that depends on "provided" libraries.
>>>>
>>>> What is the best way to test the code?
>>>>
>>>> I don't particularly want to add the shared libraries to the 
>>>> project since they are large and will add a big load into the SCM 
>>>> and make it hard to check out the project.
>>>>
>>>> Can I add the dependency twice, once as provided and once as test?
>>>> Any comments or suggestions?
>>>>
>>>> Ron
>>>>
>>>> --
>>>> Ron Wheeler
>>>> President
>>>> Artifact Software Inc
>>>> email: rwheeler@artifact-software.com 
>>>> <ma...@artifact-software.com>
>>>> skype: ronaldmwheeler
>>>> phone: 866-970-2435, ext 102
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org 
>>>> <ma...@maven.apache.org>
>>>> For additional commands, e-mail: users-help@maven.apache.org 
>>>> <ma...@maven.apache.org>
>>>>
>>> -----------------
>>> Author, Getting Started with Apache Maven 
>>> <http://www.packtpub.com/getting-started-with-apache-maven/video>
>>>
>>> Come read my webnovel, Take a Lemon <http://www.takealemon.com>,
>>> and listen to the Misfile radio play 
>>> <http://www.fuzzyfacetheater.com/misfile/>!
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Ron Wheeler
>> President
>> Artifact Software Inc
>> email:rwheeler@artifact-software.com 
>> <ma...@artifact-software.com>
>> skype: ronaldmwheeler
>> phone: 866-970-2435, ext 102
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:users-unsubscribe@maven.apache.org 
>> <ma...@maven.apache.org>
>> For additional commands, e-mail:users-help@maven.apache.org 
>> <ma...@maven.apache.org>
>
> -----------------
> Author, Getting Started with Apache Maven 
> <http://www.packtpub.com/getting-started-with-apache-maven/video>
>
> Come read my webnovel, /Take a Lemon/<http://www.takealemon.com>,
> and listen to the Misfile radio play 
> <http://www.fuzzyfacetheater.com/misfile/>!
>
>
>
>
>
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


Re: Best Practice for testing code that uses provided dependencies

Posted by Russell Gold <ru...@gold-family.us>.
On Oct 27, 2013, at 9:38 PM, Ron Wheeler <rw...@artifact-software.com> wrote:

> On 27/10/2013 7:59 PM, Russell Gold wrote:
>> I’m actually running into the same issue, and my plan was s to take advantage of the situation to provide test versions of the classes. What I found was that the “provided” dependency wound up in the test class path.
>> 
>> So I think that the fact that it is provided should have no impact on how you test it.
> I am not sure what you mean.
> If scope is provided, does that mean that you have to add the jar to the project?

> Or does "provided" turn out to be like compile when the tests are run?

Yes; if scope is “provided”, maven will make sure the jar is available on the compile class path as well as the test compile and test run class paths; however, anything that depends on your module will not inherit the dependency transitively, I believe (although I have tried this) that if you use an assembly plugin to package your project, it will ignore the provided dependency. I’m not sure what you mean by “add the jar to the project.”

> 
> I guess that Eclipse does not understand that. It can not resolve the imports. Not really a maven problem

It seems to work in IntellijIDEA, though.

> 
>> 
>> - Russ
>> 
>> On Oct 27, 2013, at 7:22 PM, Ron Wheeler <rw...@artifact-software.com> wrote:
>> 
>>> We have code that depends on "provided" libraries.
>>> 
>>> What is the best way to test the code?
>>> 
>>> I don't particularly want to add the shared libraries to the project since they are large and will add a big load into the SCM and make it hard to check out the project.
>>> 
>>> Can I add the dependency twice, once as provided and once as test?
>>> Any comments or suggestions?
>>> 
>>> Ron
>>> 
>>> -- 
>>> Ron Wheeler
>>> President
>>> Artifact Software Inc
>>> email: rwheeler@artifact-software.com
>>> skype: ronaldmwheeler
>>> phone: 866-970-2435, ext 102
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>> 
>> -----------------
>> Author, Getting Started with Apache Maven <http://www.packtpub.com/getting-started-with-apache-maven/video>
>> 
>> Come read my webnovel, Take a Lemon <http://www.takealemon.com>,
>> and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> -- 
> Ron Wheeler
> President
> Artifact Software Inc
> email: rwheeler@artifact-software.com
> skype: ronaldmwheeler
> phone: 866-970-2435, ext 102
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

-----------------
Author, Getting Started with Apache Maven <http://www.packtpub.com/getting-started-with-apache-maven/video>

Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!








Re: Best Practice for testing code that uses provided dependencies

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 27/10/2013 7:59 PM, Russell Gold wrote:
> I’m actually running into the same issue, and my plan was s to take advantage of the situation to provide test versions of the classes. What I found was that the “provided” dependency wound up in the test class path.
>
> So I think that the fact that it is provided should have no impact on how you test it.
I am not sure what you mean.
If scope is provided, does that mean that you have to add the jar to the 
project?
Or does "provided" turn out to be like compile when the tests are run?

I guess that Eclipse does not understand that. It can not resolve the 
imports. Not really a maven problem

>
> - Russ
>
> On Oct 27, 2013, at 7:22 PM, Ron Wheeler <rw...@artifact-software.com> wrote:
>
>> We have code that depends on "provided" libraries.
>>
>> What is the best way to test the code?
>>
>> I don't particularly want to add the shared libraries to the project since they are large and will add a big load into the SCM and make it hard to check out the project.
>>
>> Can I add the dependency twice, once as provided and once as test?
>> Any comments or suggestions?
>>
>> Ron
>>
>> -- 
>> Ron Wheeler
>> President
>> Artifact Software Inc
>> email: rwheeler@artifact-software.com
>> skype: ronaldmwheeler
>> phone: 866-970-2435, ext 102
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
> -----------------
> Author, Getting Started with Apache Maven <http://www.packtpub.com/getting-started-with-apache-maven/video>
>
> Come read my webnovel, Take a Lemon <http://www.takealemon.com>,
> and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!
>
>
>
>
>
>
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Best Practice for testing code that uses provided dependencies

Posted by Russell Gold <ru...@gold-family.us>.
I’m actually running into the same issue, and my plan was s to take advantage of the situation to provide test versions of the classes. What I found was that the “provided” dependency wound up in the test class path.

So I think that the fact that it is provided should have no impact on how you test it.

- Russ

On Oct 27, 2013, at 7:22 PM, Ron Wheeler <rw...@artifact-software.com> wrote:

> We have code that depends on "provided" libraries.
> 
> What is the best way to test the code?
> 
> I don't particularly want to add the shared libraries to the project since they are large and will add a big load into the SCM and make it hard to check out the project.
> 
> Can I add the dependency twice, once as provided and once as test?
> Any comments or suggestions?
> 
> Ron
> 
> -- 
> Ron Wheeler
> President
> Artifact Software Inc
> email: rwheeler@artifact-software.com
> skype: ronaldmwheeler
> phone: 866-970-2435, ext 102
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

-----------------
Author, Getting Started with Apache Maven <http://www.packtpub.com/getting-started-with-apache-maven/video>

Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!