You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Shane Isbell <sh...@gmail.com> on 2012/06/13 21:17:57 UTC

Maven SureFire Plugin: Android Provider

Hi all,

I'm working on an android provider for surefire. Generally, I have things
working but have encountered a specific problem. The unit tests are running
remotely on a device (not the build machine). For the surefire xml report,
I need to pull in the system properties on the device, not those on the
build machine.

The StartupReportConfiguration.instantiateXmlReporter is hardcoded to
return XMLReporter. AbstractSurefireMojo.createForkStarter is, in turn,
hardcoded to use StartReportConfiguration.

So I'm unable to replace the StartReportConfiguration with a class
implementation that will return a specialized XMLReporter instance that
will return device system properties.

Is there a way to handle this situation through the surefire API or is this
something I need to create a patch for?

Thanks,
Shane

Re: Maven SureFire Plugin: Android Provider

Posted by Manfred Moser <ma...@mosabuam.com>.
Great... well done. This looks really good from my glance at the code..

manfred

On Thu, June 14, 2012 3:24 pm, Shane Isbell wrote:
> Thanks for the responses Kristian, Manfred. I did find that in the the
> android provider I can specialize the StartupReportConfiguration class
> (that returns custom xml reporter). Then I just use the
> StartupReportConfiguration as a parameter in FileReporterFactory.new. The
> reporter is then setup correctly.
>
> Thanks,
> Shane
>
> On Wed, Jun 13, 2012 at 4:38 PM, Shane Isbell
> <sh...@gmail.com>wrote:
>
>> Android has it's own RemoteAndroidTestRunner, so I just invoke the
>> RemoteAndroidTestRunner.run method to kick off the Android junit tests.
>>
>> Surefire has a report test lifecycle: testSetStarting,
>> testFailed...These
>> methods map closely to the events in the RemoteAndroidTestRunner. So I
>> just
>> created a simple mapping. For an early prototype see:
>>
>> http://tinyurl.com/7rrv6cx
>>
>> So I would prefer not to run surefire code directly on the device.
>>
>> I follow the path:
>>
>> AbstractSurefireMojo.executeProvider - >
>> AbstractSurefireMojo.createForkStarter ->
>> AbstractSurefireMojo.getStartupReportConfiguration - > ForkStarter.new
>>
>> I just don't see how to configure the StartupReportConfiguration to
>> return
>> a customized XMLReporter (this reporter implementation queries the
>> device
>> for its system properties).
>>
>> I'll keep digging around...but appreciate any further pointers.
>>
>> Thanks,
>> Shane
>>
>>
>> On Wed, Jun 13, 2012 at 1:12 PM, Kristian Rosenvold <
>> kristian.rosenvold@gmail.com> wrote:
>>
>>> I would somehow assume that the sensible way to implement an android
>>> provider would be to extend the current forking logic to serialize the
>>> entire fork to a remote machine. Furthermore there is already support
>>> for bringing the system properties from the fork back to the plugin,
>>> which would come for "free" in this case. I would be considering
>>> starting the fork in/around the "ForkStarter" java class.
>>>
>>> Something in your question makes me think you're starting the fork
>>> differently?
>>>
>>> Kristian
>>>
>>>
>>> 2012/6/13 Shane Isbell <sh...@gmail.com>:
>>> > Hi all,
>>> >
>>> > I'm working on an android provider for surefire. Generally, I have
>>> things
>>> > working but have encountered a specific problem. The unit tests are
>>> running
>>> > remotely on a device (not the build machine). For the surefire xml
>>> report,
>>> > I need to pull in the system properties on the device, not those on
>>> the
>>> > build machine.
>>> >
>>> > The StartupReportConfiguration.instantiateXmlReporter is hardcoded to
>>> > return XMLReporter. AbstractSurefireMojo.createForkStarter is, in
>>> turn,
>>> > hardcoded to use StartReportConfiguration.
>>> >
>>> > So I'm unable to replace the StartReportConfiguration with a class
>>> > implementation that will return a specialized XMLReporter instance
>>> that
>>> > will return device system properties.
>>> >
>>> > Is there a way to handle this situation through the surefire API or
>>> is
>>> this
>>> > something I need to create a patch for?
>>> >
>>> > Thanks,
>>> > Shane
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>>
>>
>


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


Re: Maven SureFire Plugin: Android Provider

Posted by Shane Isbell <sh...@gmail.com>.
Thanks for the responses Kristian, Manfred. I did find that in the the
android provider I can specialize the StartupReportConfiguration class
(that returns custom xml reporter). Then I just use the
StartupReportConfiguration as a parameter in FileReporterFactory.new. The
reporter is then setup correctly.

Thanks,
Shane

On Wed, Jun 13, 2012 at 4:38 PM, Shane Isbell <sh...@gmail.com>wrote:

> Android has it's own RemoteAndroidTestRunner, so I just invoke the
> RemoteAndroidTestRunner.run method to kick off the Android junit tests.
>
> Surefire has a report test lifecycle: testSetStarting, testFailed...These
> methods map closely to the events in the RemoteAndroidTestRunner. So I just
> created a simple mapping. For an early prototype see:
>
> http://tinyurl.com/7rrv6cx
>
> So I would prefer not to run surefire code directly on the device.
>
> I follow the path:
>
> AbstractSurefireMojo.executeProvider - >
> AbstractSurefireMojo.createForkStarter ->
> AbstractSurefireMojo.getStartupReportConfiguration - > ForkStarter.new
>
> I just don't see how to configure the StartupReportConfiguration to return
> a customized XMLReporter (this reporter implementation queries the device
> for its system properties).
>
> I'll keep digging around...but appreciate any further pointers.
>
> Thanks,
> Shane
>
>
> On Wed, Jun 13, 2012 at 1:12 PM, Kristian Rosenvold <
> kristian.rosenvold@gmail.com> wrote:
>
>> I would somehow assume that the sensible way to implement an android
>> provider would be to extend the current forking logic to serialize the
>> entire fork to a remote machine. Furthermore there is already support
>> for bringing the system properties from the fork back to the plugin,
>> which would come for "free" in this case. I would be considering
>> starting the fork in/around the "ForkStarter" java class.
>>
>> Something in your question makes me think you're starting the fork
>> differently?
>>
>> Kristian
>>
>>
>> 2012/6/13 Shane Isbell <sh...@gmail.com>:
>> > Hi all,
>> >
>> > I'm working on an android provider for surefire. Generally, I have
>> things
>> > working but have encountered a specific problem. The unit tests are
>> running
>> > remotely on a device (not the build machine). For the surefire xml
>> report,
>> > I need to pull in the system properties on the device, not those on the
>> > build machine.
>> >
>> > The StartupReportConfiguration.instantiateXmlReporter is hardcoded to
>> > return XMLReporter. AbstractSurefireMojo.createForkStarter is, in turn,
>> > hardcoded to use StartReportConfiguration.
>> >
>> > So I'm unable to replace the StartReportConfiguration with a class
>> > implementation that will return a specialized XMLReporter instance that
>> > will return device system properties.
>> >
>> > Is there a way to handle this situation through the surefire API or is
>> this
>> > something I need to create a patch for?
>> >
>> > Thanks,
>> > Shane
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>

Re: Maven SureFire Plugin: Android Provider

Posted by Shane Isbell <sh...@gmail.com>.
Android has it's own RemoteAndroidTestRunner, so I just invoke the
RemoteAndroidTestRunner.run method to kick off the Android junit tests.

Surefire has a report test lifecycle: testSetStarting, testFailed...These
methods map closely to the events in the RemoteAndroidTestRunner. So I just
created a simple mapping. For an early prototype see:

http://tinyurl.com/7rrv6cx

So I would prefer not to run surefire code directly on the device.

I follow the path:

AbstractSurefireMojo.executeProvider - >
AbstractSurefireMojo.createForkStarter ->
AbstractSurefireMojo.getStartupReportConfiguration - > ForkStarter.new

I just don't see how to configure the StartupReportConfiguration to return
a customized XMLReporter (this reporter implementation queries the device
for its system properties).

I'll keep digging around...but appreciate any further pointers.

Thanks,
Shane

On Wed, Jun 13, 2012 at 1:12 PM, Kristian Rosenvold <
kristian.rosenvold@gmail.com> wrote:

> I would somehow assume that the sensible way to implement an android
> provider would be to extend the current forking logic to serialize the
> entire fork to a remote machine. Furthermore there is already support
> for bringing the system properties from the fork back to the plugin,
> which would come for "free" in this case. I would be considering
> starting the fork in/around the "ForkStarter" java class.
>
> Something in your question makes me think you're starting the fork
> differently?
>
> Kristian
>
>
> 2012/6/13 Shane Isbell <sh...@gmail.com>:
> > Hi all,
> >
> > I'm working on an android provider for surefire. Generally, I have things
> > working but have encountered a specific problem. The unit tests are
> running
> > remotely on a device (not the build machine). For the surefire xml
> report,
> > I need to pull in the system properties on the device, not those on the
> > build machine.
> >
> > The StartupReportConfiguration.instantiateXmlReporter is hardcoded to
> > return XMLReporter. AbstractSurefireMojo.createForkStarter is, in turn,
> > hardcoded to use StartReportConfiguration.
> >
> > So I'm unable to replace the StartReportConfiguration with a class
> > implementation that will return a specialized XMLReporter instance that
> > will return device system properties.
> >
> > Is there a way to handle this situation through the surefire API or is
> this
> > something I need to create a patch for?
> >
> > Thanks,
> > Shane
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Maven SureFire Plugin: Android Provider

Posted by Kristian Rosenvold <kr...@gmail.com>.
I would somehow assume that the sensible way to implement an android
provider would be to extend the current forking logic to serialize the
entire fork to a remote machine. Furthermore there is already support
for bringing the system properties from the fork back to the plugin,
which would come for "free" in this case. I would be considering
starting the fork in/around the "ForkStarter" java class.

Something in your question makes me think you're starting the fork differently?

Kristian


2012/6/13 Shane Isbell <sh...@gmail.com>:
> Hi all,
>
> I'm working on an android provider for surefire. Generally, I have things
> working but have encountered a specific problem. The unit tests are running
> remotely on a device (not the build machine). For the surefire xml report,
> I need to pull in the system properties on the device, not those on the
> build machine.
>
> The StartupReportConfiguration.instantiateXmlReporter is hardcoded to
> return XMLReporter. AbstractSurefireMojo.createForkStarter is, in turn,
> hardcoded to use StartReportConfiguration.
>
> So I'm unable to replace the StartReportConfiguration with a class
> implementation that will return a specialized XMLReporter instance that
> will return device system properties.
>
> Is there a way to handle this situation through the surefire API or is this
> something I need to create a patch for?
>
> Thanks,
> Shane

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


Re: Maven SureFire Plugin: Android Provider

Posted by Manfred Moser <ma...@mosabuam.com>.
On Wed, June 13, 2012 12:17 pm, Shane Isbell wrote:
> Hi all,
>
> I'm working on an android provider for surefire. Generally, I have things
> working but have encountered a specific problem. The unit tests are
> running
> remotely on a device (not the build machine). For the surefire xml report,
> I need to pull in the system properties on the device, not those on the
> build machine.

If you use ddmlib you can pull them in via that api from the device to the
build machine. The android maven plugin actually already has a class that
does that as well as one that assembles the junit test report on the build
machine rather than the device .. which works much better. Ping me for
pointers since I wrote all that..

manfred
http://www.simpligility.com

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