I've been working a lot in the framework, and I would like to get some automated tests in there. The problem is, there is no "test" ant target at the component level. Is there a way that can be done? I'm not familiar with ant build.xml files, so could someone help out with that?
-Adrian |
Hi Adrian,
To run a component specific JUnit tests you can use java -jar ofbiz.jar -test -component='component-name'. I used it a long ago and I can recall pretty surely that it worked. And if this works, I believe ant run-tests -component='component-name' should also work. Just in case the above commands do not work (which I doubt) then we should add this support to the framework. -- Thanks, Mridul Pathak On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: > I've been working a lot in the framework, and I would like to get > some automated tests in there. The problem is, there is no "test" > ant target at the component level. Is there a way that can be done? > I'm not familiar with ant build.xml files, so could someone help out > with that? > > -Adrian > > > > |
Mridul,
Thank you! I have to confess, I don't use the command line often (actually never). I was referring to running tests from within Eclipse. But I'll give your suggestion a try! -Adrian --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> wrote: > From: Mridul Pathak <[hidden email]> > Subject: Re: OFBiz Tests and Ant build.xml Files > To: [hidden email] > Cc: "Mridul Pathak" <[hidden email]> > Date: Friday, November 6, 2009, 8:22 PM > Hi Adrian, > > To run a component specific JUnit tests you > can use java -jar ofbiz.jar -test > -component='component-name'. I used it a long ago and > I can recall pretty surely that it worked. And if this > works, I believe ant run-tests -component='component-name' > should also work. > Just in case the above commands do not work > (which I doubt) then we should add this support to the > framework. > > -- > Thanks, > Mridul Pathak > > On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: > > > I've been working a lot in the framework, and I would > like to get some automated tests in there. The problem is, > there is no "test" ant target at the component level. Is > there a way that can be done? I'm not familiar with ant > build.xml files, so could someone help out with that? > > > > -Adrian > > > > > > > > > > |
I was wrong about the ant target support. There isn't any, its only
possible with "java -jar ofbiz.jar". We can definitely add such targets. Following are the basic targets that we can add: 1) ant run-tests-component -Dcomponent=component-name 2) ant run-test-suite -Dsuitename=test-suite-name 3) a combination of #1 and #2, I can't think a good name for this one, please suggest. 4) we may add a target to run a specific test-case in a particular test-suite too, but I'll have to look for the available support once. Please let me know what do you think of above listed targets and I can provide the patch for it. Also would they by of help while running tests within Eclipse, I haven't ever tried it as I always use command line. Looking forward to the thoughts of community as well. -- Thanks, Mridul Pathak On 07-Nov-09, at 12:38 PM, Adrian Crum wrote: > Mridul, > > Thank you! I have to confess, I don't use the command line often > (actually never). I was referring to running tests from within > Eclipse. But I'll give your suggestion a try! > > -Adrian > > > --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> > wrote: > >> From: Mridul Pathak <[hidden email]> >> Subject: Re: OFBiz Tests and Ant build.xml Files >> To: [hidden email] >> Cc: "Mridul Pathak" <[hidden email]> >> Date: Friday, November 6, 2009, 8:22 PM >> Hi Adrian, >> >> To run a component specific JUnit tests you >> can use java -jar ofbiz.jar -test >> -component='component-name'. I used it a long ago and >> I can recall pretty surely that it worked. And if this >> works, I believe ant run-tests -component='component-name' >> should also work. >> Just in case the above commands do not work >> (which I doubt) then we should add this support to the >> framework. >> >> -- >> Thanks, >> Mridul Pathak >> >> On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: >> >>> I've been working a lot in the framework, and I would >> like to get some automated tests in there. The problem is, >> there is no "test" ant target at the component level. Is >> there a way that can be done? I'm not familiar with ant >> build.xml files, so could someone help out with that? >>> >>> -Adrian >>> >>> >>> >>> >> >> > > > |
I checked it again, there are few available. Please see my comments
inline. -- Thanks, Mridul Pathak On 07-Nov-09, at 12:54 PM, Mridul Pathak wrote: > I was wrong about the ant target support. There isn't any, its only > possible with "java -jar ofbiz.jar". We can definitely add such > targets. Following are the basic targets that we can add: > > 1) ant run-tests-component -Dcomponent=component-name Not Available. We can still add this one, looks like it will be useful. > 2) ant run-test-suite -Dsuitename=test-suite-name Available. It is ant run-single-test-suite, takes test.component and test.suiteName as arguments. > 3) a combination of #1 and #2, I can't think a good name for this > one, please suggest. #2 serves it. > 4) we may add a target to run a specific test-case in a particular > test-suite too, but I'll have to look for the available support once. Available. It is ant run-single-test, takes test.component and test.case as arguments. > > Please let me know what do you think of above listed targets and I > can provide the patch for it. Also would they by of help while > running tests within Eclipse, I haven't ever tried it as I always > use command line. Looking forward to the thoughts of community as > well. > > -- > Thanks, > Mridul Pathak > > On 07-Nov-09, at 12:38 PM, Adrian Crum wrote: > >> Mridul, >> >> Thank you! I have to confess, I don't use the command line often >> (actually never). I was referring to running tests from within >> Eclipse. But I'll give your suggestion a try! >> >> -Adrian >> >> >> --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> >> wrote: >> >>> From: Mridul Pathak <[hidden email]> >>> Subject: Re: OFBiz Tests and Ant build.xml Files >>> To: [hidden email] >>> Cc: "Mridul Pathak" <[hidden email]> >>> Date: Friday, November 6, 2009, 8:22 PM >>> Hi Adrian, >>> >>> To run a component specific JUnit tests you >>> can use java -jar ofbiz.jar -test >>> -component='component-name'. I used it a long ago and >>> I can recall pretty surely that it worked. And if this >>> works, I believe ant run-tests -component='component-name' >>> should also work. >>> Just in case the above commands do not work >>> (which I doubt) then we should add this support to the >>> framework. >>> >>> -- >>> Thanks, >>> Mridul Pathak >>> >>> On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: >>> >>>> I've been working a lot in the framework, and I would >>> like to get some automated tests in there. The problem is, >>> there is no "test" ant target at the component level. Is >>> there a way that can be done? I'm not familiar with ant >>> build.xml files, so could someone help out with that? >>>> >>>> -Adrian >>>> >>>> >>>> >>>> >>> >>> >> >> >> > |
Administrator
|
Please Mridul,
If you add ant targets don't forget to put descriptions I find ant -p very convenient Thanks Jacques From: "Mridul Pathak" <[hidden email]> >I checked it again, there are few available. Please see my comments > inline. > > -- > Thanks, > Mridul Pathak > > On 07-Nov-09, at 12:54 PM, Mridul Pathak wrote: > >> I was wrong about the ant target support. There isn't any, its only >> possible with "java -jar ofbiz.jar". We can definitely add such >> targets. Following are the basic targets that we can add: >> >> 1) ant run-tests-component -Dcomponent=component-name > > Not Available. We can still add this one, looks like it will be useful. > >> 2) ant run-test-suite -Dsuitename=test-suite-name > > Available. It is ant run-single-test-suite, takes test.component and > test.suiteName as arguments. > >> 3) a combination of #1 and #2, I can't think a good name for this >> one, please suggest. > > #2 serves it. > >> 4) we may add a target to run a specific test-case in a particular >> test-suite too, but I'll have to look for the available support once. > > Available. It is ant run-single-test, takes test.component and > test.case as arguments. > >> >> Please let me know what do you think of above listed targets and I >> can provide the patch for it. Also would they by of help while >> running tests within Eclipse, I haven't ever tried it as I always >> use command line. Looking forward to the thoughts of community as >> well. >> >> -- >> Thanks, >> Mridul Pathak >> >> On 07-Nov-09, at 12:38 PM, Adrian Crum wrote: >> >>> Mridul, >>> >>> Thank you! I have to confess, I don't use the command line often >>> (actually never). I was referring to running tests from within >>> Eclipse. But I'll give your suggestion a try! >>> >>> -Adrian >>> >>> >>> --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> >>> wrote: >>> >>>> From: Mridul Pathak <[hidden email]> >>>> Subject: Re: OFBiz Tests and Ant build.xml Files >>>> To: [hidden email] >>>> Cc: "Mridul Pathak" <[hidden email]> >>>> Date: Friday, November 6, 2009, 8:22 PM >>>> Hi Adrian, >>>> >>>> To run a component specific JUnit tests you >>>> can use java -jar ofbiz.jar -test >>>> -component='component-name'. I used it a long ago and >>>> I can recall pretty surely that it worked. And if this >>>> works, I believe ant run-tests -component='component-name' >>>> should also work. >>>> Just in case the above commands do not work >>>> (which I doubt) then we should add this support to the >>>> framework. >>>> >>>> -- >>>> Thanks, >>>> Mridul Pathak >>>> >>>> On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: >>>> >>>>> I've been working a lot in the framework, and I would >>>> like to get some automated tests in there. The problem is, >>>> there is no "test" ant target at the component level. Is >>>> there a way that can be done? I'm not familiar with ant >>>> build.xml files, so could someone help out with that? >>>>> >>>>> -Adrian >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >>> >> > > |
Sure Jacques,
I'll keep that in mind. -- Thanks, Mridul Pathak On 07-Nov-09, at 1:32 PM, Jacques Le Roux wrote: > Please Mridul, > > If you add ant targets don't forget to put descriptions > I find ant -p very convenient > > Thanks > > Jacques > > From: "Mridul Pathak" <[hidden email]> >> I checked it again, there are few available. Please see my >> comments inline. >> -- >> Thanks, >> Mridul Pathak >> On 07-Nov-09, at 12:54 PM, Mridul Pathak wrote: >>> I was wrong about the ant target support. There isn't any, its >>> only possible with "java -jar ofbiz.jar". We can definitely add >>> such targets. Following are the basic targets that we can add: >>> >>> 1) ant run-tests-component -Dcomponent=component-name >> Not Available. We can still add this one, looks like it will be >> useful. >>> 2) ant run-test-suite -Dsuitename=test-suite-name >> Available. It is ant run-single-test-suite, takes test.component >> and test.suiteName as arguments. >>> 3) a combination of #1 and #2, I can't think a good name for this >>> one, please suggest. >> #2 serves it. >>> 4) we may add a target to run a specific test-case in a >>> particular test-suite too, but I'll have to look for the >>> available support once. >> Available. It is ant run-single-test, takes test.component and >> test.case as arguments. >>> >>> Please let me know what do you think of above listed targets and >>> I can provide the patch for it. Also would they by of help >>> while running tests within Eclipse, I haven't ever tried it as I >>> always use command line. Looking forward to the thoughts of >>> community as well. >>> >>> -- >>> Thanks, >>> Mridul Pathak >>> >>> On 07-Nov-09, at 12:38 PM, Adrian Crum wrote: >>> >>>> Mridul, >>>> >>>> Thank you! I have to confess, I don't use the command line often >>>> (actually never). I was referring to running tests from within >>>> Eclipse. But I'll give your suggestion a try! >>>> >>>> -Adrian >>>> >>>> >>>> --- On Fri, 11/6/09, Mridul Pathak >>>> <[hidden email]> wrote: >>>> >>>>> From: Mridul Pathak <[hidden email]> >>>>> Subject: Re: OFBiz Tests and Ant build.xml Files >>>>> To: [hidden email] >>>>> Cc: "Mridul Pathak" <[hidden email]> >>>>> Date: Friday, November 6, 2009, 8:22 PM >>>>> Hi Adrian, >>>>> >>>>> To run a component specific JUnit tests you >>>>> can use java -jar ofbiz.jar -test >>>>> -component='component-name'. I used it a long ago and >>>>> I can recall pretty surely that it worked. And if this >>>>> works, I believe ant run-tests -component='component-name' >>>>> should also work. >>>>> Just in case the above commands do not work >>>>> (which I doubt) then we should add this support to the >>>>> framework. >>>>> >>>>> -- >>>>> Thanks, >>>>> Mridul Pathak >>>>> >>>>> On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: >>>>> >>>>>> I've been working a lot in the framework, and I would >>>>> like to get some automated tests in there. The problem is, >>>>> there is no "test" ant target at the component level. Is >>>>> there a way that can be done? I'm not familiar with ant >>>>> build.xml files, so could someone help out with that? >>>>>> >>>>>> -Adrian >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >> > |
In reply to this post by Adrian Crum-2
Adrian --
While this is probably not the best practice, what we have done is create a set of abstract base classes that extend the JUnit test case. Depending on the architectural layer we are testing, these may just provide some helper methods or they may start the container and allow us to run the JUnit from in Eclipse. The penalty we pay on the longer running tests is usually around 15 seconds or so; but it does allow us to run a whole suite of test cases in Eclipse with only the container start-up penalty. In an effort to focus specifically on the business logic in service implementations, we have also made some use of Mockito. The "StandaloneMockTestCase" that we extend here avoids starting up the container and allows us to mock out both the delegator and dispatcher. This provided very targeted unit tests (usually as part of code coverage metrics) while mocking out external dependencies. If at all interested, I created a JIRA ticket and attached some source that displayed this technique. What we have not done is figure out how to integrate our unit tests with the standard ones in JUnit and have them all run as part of our automated build scripts. Currently, we only run our own unit tests. We also have not done enough work building up TestSuites at the various architectural layers as well as for each component. To be honest, I am unsure if we are even doing this in the best possible way. I started out trying to create debug configurations that would execute specific unit tests / component tests with the arguments to Start but I found it rather tedious. Moreover, it did not allow us to leverage the good tooling in the IDE. ----- Original Message ----- From: Adrian Crum <[hidden email]> To: [hidden email] Sent: Sat, 7 Nov 2009 02:08:54 -0500 (EST) Subject: Re: OFBiz Tests and Ant build.xml Files Mridul, Thank you! I have to confess, I don't use the command line often (actually never). I was referring to running tests from within Eclipse. But I'll give your suggestion a try! -Adrian --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> wrote: > From: Mridul Pathak <[hidden email]> > Subject: Re: OFBiz Tests and Ant build.xml Files > To: [hidden email] > Cc: "Mridul Pathak" <[hidden email]> > Date: Friday, November 6, 2009, 8:22 PM > Hi Adrian, > > To run a component specific JUnit tests you > can use java -jar ofbiz.jar -test > -component='component-name'. I used it a long ago and > I can recall pretty surely that it worked. And if this > works, I believe ant run-tests -component='component-name' > should also work. > Just in case the above commands do not work > (which I doubt) then we should add this support to the > framework. > > -- > Thanks, > Mridul Pathak > > On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: > > > I've been working a lot in the framework, and I would > like to get some automated tests in there. The problem is, > there is no "test" ant target at the component level. Is > there a way that can be done? I'm not familiar with ant > build.xml files, so could someone help out with that? > > > > -Adrian > > > > > > > > > > |
In reply to this post by Adrian Crum-2
Another package used in testing is spring's mock servlet package 'org.springframework.mock.web'. (http://bit.ly/4zEAJF)
Mockito intercepts calls with interception setup and checking in junit test. Very general purpose and can be used for servlets, delegators etc. Downside is that a parameter from a ServletRequest can be obtained many ways(getParameterMap, getParameterValues, getParameter etc.) and sometimes not worth trying to cover all ways. Mock Servlets allow tests to create your own request and session, then create your context and then call whatever you need to - service, groovy, screen render etc. and check results. Easier setup but less general. The trick to running multiple tests together was to hold on to hold on to singleton instance of 'Start' and intialize only if needed in base class of all tests your top level test case class { ... static Start start; @Override protected void setUp() throws Exception { if (start == null) { ... start = new Start(); start.init(new String[]{"test"}); ... new EntityConfigUtil().start(); } ... } ... } Harmeet ----- Original Message ----- From: "Robert Morley" <[hidden email]> To: [hidden email] Sent: Tuesday, November 10, 2009 11:31:39 PM GMT -05:00 US/Canada Eastern Subject: Re: OFBiz Tests and Ant build.xml Files Adrian -- While this is probably not the best practice, what we have done is create a set of abstract base classes that extend the JUnit test case. Depending on the architectural layer we are testing, these may just provide some helper methods or they may start the container and allow us to run the JUnit from in Eclipse. The penalty we pay on the longer running tests is usually around 15 seconds or so; but it does allow us to run a whole suite of test cases in Eclipse with only the container start-up penalty. In an effort to focus specifically on the business logic in service implementations, we have also made some use of Mockito. The "StandaloneMockTestCase" that we extend here avoids starting up the container and allows us to mock out both the delegator and dispatcher. This provided very targeted unit tests (usually as part of code coverage metrics) while mocking out external dependencies. If at all interested, I created a JIRA ticket and attached some source that displayed this technique. What we have not done is figure out how to integrate our unit tests with the standard ones in JUnit and have them all run as part of our automated build scripts. Currently, we only run our own unit tests. We also have not done enough work building up TestSuites at the various architectural layers as well as for each component. To be honest, I am unsure if we are even doing this in the best possible way. I started out trying to create debug configurations that would execute specific unit tests / component tests with the arguments to Start but I found it rather tedious. Moreover, it did not allow us to leverage the good tooling in the IDE. ----- Original Message ----- From: Adrian Crum <[hidden email]> To: [hidden email] Sent: Sat, 7 Nov 2009 02:08:54 -0500 (EST) Subject: Re: OFBiz Tests and Ant build.xml Files Mridul, Thank you! I have to confess, I don't use the command line often (actually never). I was referring to running tests from within Eclipse. But I'll give your suggestion a try! -Adrian --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> wrote: > From: Mridul Pathak <[hidden email]> > Subject: Re: OFBiz Tests and Ant build.xml Files > To: [hidden email] > Cc: "Mridul Pathak" <[hidden email]> > Date: Friday, November 6, 2009, 8:22 PM > Hi Adrian, > > To run a component specific JUnit tests you > can use java -jar ofbiz.jar -test > -component='component-name'. I used it a long ago and > I can recall pretty surely that it worked. And if this > works, I believe ant run-tests -component='component-name' > should also work. > Just in case the above commands do not work > (which I doubt) then we should add this support to the > framework. > > -- > Thanks, > Mridul Pathak > > On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: > > > I've been working a lot in the framework, and I would > like to get some automated tests in there. The problem is, > there is no "test" ant target at the component level. Is > there a way that can be done? I'm not familiar with ant > build.xml files, so could someone help out with that? > > > > -Adrian > > > > > > > > > > |
In reply to this post by Adrian Crum-2
What the static 'start' gives you is that you can run single or group of tests with one single container initialization and you can right click and tests in eclipse without caring about running container.. Not sure if there is a better way but need the container setup somehow and shared by junit tests.
----- Original Message ----- From: "Harmeet Bedi" <[hidden email]> To: [hidden email] Sent: Wednesday, November 11, 2009 1:19:37 AM GMT -05:00 US/Canada Eastern Subject: Re: OFBiz Tests and Ant build.xml Files Another package used in testing is spring's mock servlet package 'org.springframework.mock.web'. (http://bit.ly/4zEAJF) Mockito intercepts calls with interception setup and checking in junit test. Very general purpose and can be used for servlets, delegators etc. Downside is that a parameter from a ServletRequest can be obtained many ways(getParameterMap, getParameterValues, getParameter etc.) and sometimes not worth trying to cover all ways. Mock Servlets allow tests to create your own request and session, then create your context and then call whatever you need to - service, groovy, screen render etc. and check results. Easier setup but less general. The trick to running multiple tests together was to hold on to hold on to singleton instance of 'Start' and intialize only if needed in base class of all tests your top level test case class { ... static Start start; @Override protected void setUp() throws Exception { if (start == null) { ... start = new Start(); start.init(new String[]{"test"}); ... new EntityConfigUtil().start(); } ... } ... } Harmeet ----- Original Message ----- From: "Robert Morley" <[hidden email]> To: [hidden email] Sent: Tuesday, November 10, 2009 11:31:39 PM GMT -05:00 US/Canada Eastern Subject: Re: OFBiz Tests and Ant build.xml Files Adrian -- While this is probably not the best practice, what we have done is create a set of abstract base classes that extend the JUnit test case. Depending on the architectural layer we are testing, these may just provide some helper methods or they may start the container and allow us to run the JUnit from in Eclipse. The penalty we pay on the longer running tests is usually around 15 seconds or so; but it does allow us to run a whole suite of test cases in Eclipse with only the container start-up penalty. In an effort to focus specifically on the business logic in service implementations, we have also made some use of Mockito. The "StandaloneMockTestCase" that we extend here avoids starting up the container and allows us to mock out both the delegator and dispatcher. This provided very targeted unit tests (usually as part of code coverage metrics) while mocking out external dependencies. If at all interested, I created a JIRA ticket and attached some source that displayed this technique. What we have not done is figure out how to integrate our unit tests with the standard ones in JUnit and have them all run as part of our automated build scripts. Currently, we only run our own unit tests. We also have not done enough work building up TestSuites at the various architectural layers as well as for each component. To be honest, I am unsure if we are even doing this in the best possible way. I started out trying to create debug configurations that would execute specific unit tests / component tests with the arguments to Start but I found it rather tedious. Moreover, it did not allow us to leverage the good tooling in the IDE. ----- Original Message ----- From: Adrian Crum <[hidden email]> To: [hidden email] Sent: Sat, 7 Nov 2009 02:08:54 -0500 (EST) Subject: Re: OFBiz Tests and Ant build.xml Files Mridul, Thank you! I have to confess, I don't use the command line often (actually never). I was referring to running tests from within Eclipse. But I'll give your suggestion a try! -Adrian --- On Fri, 11/6/09, Mridul Pathak <[hidden email]> wrote: > From: Mridul Pathak <[hidden email]> > Subject: Re: OFBiz Tests and Ant build.xml Files > To: [hidden email] > Cc: "Mridul Pathak" <[hidden email]> > Date: Friday, November 6, 2009, 8:22 PM > Hi Adrian, > > To run a component specific JUnit tests you > can use java -jar ofbiz.jar -test > -component='component-name'. I used it a long ago and > I can recall pretty surely that it worked. And if this > works, I believe ant run-tests -component='component-name' > should also work. > Just in case the above commands do not work > (which I doubt) then we should add this support to the > framework. > > -- > Thanks, > Mridul Pathak > > On 07-Nov-09, at 8:28 AM, Adrian Crum wrote: > > > I've been working a lot in the framework, and I would > like to get some automated tests in there. The problem is, > there is no "test" ant target at the component level. Is > there a way that can be done? I'm not familiar with ant > build.xml files, so could someone help out with that? > > > > -Adrian > > > > > > > > > > |
Free forum by Nabble | Edit this page |