Hi Pranay,

What you are talking about is integration tests (ones that you can run per
component)

Unit tests do not need to be run per component. The entire unit test
library for the entire framework should run in probably less than 5
seconds. So there is no need to make them run per component.

My proposal is to simply have a target like run-unit-tests which would run
all the unit tests. These tests do not talk to the database or server or
anything, You can run them while flying in an airplane 30,000 feet above
the ocean.

Mind you I will not remove the integration tests, I'm just adding unit
tests (and probably moving some integration tests to unit tests).

Naturally, my proposition means that those tests are only JUnit tests (for
now) but that is a quick solution that I think is rather clean because
we're not really radically modifying anything, we're just adding JUnit
classes and running them.

Regards,

Taher Alkhateeb

On Wed, Jun 8, 2016 at 12:23 PM, Pranay Pandey <
pranay.pan...@hotwaxsystems.com> wrote:

> Hi Taher,
>
> There is one thing that I want to confirm based my understanding, as long
> as I know, we can run tests independently as well e.g.
>
> *Running tests for a component: *
>
> java -jar ofbiz.jar -test component=‘order’
>
> *Running a specific test Suite from a component:*
>
> ant run-single-test-suite -Dtest.component=‘order’ -Dtest.suiteName='
> ordertests'
>
> *Running a test case from a component:*
>
> java -jar ofbiz.jar -test -component='order' -case='salesOrder-test'
>
> I may be completely wrong here but just want to confirm and understand your
> proposal.
>
> Best regards,
>
> Pranay Pandey
> HotWax Systems
> http://www.hotwaxsystems.com/
>
> On Wed, Jun 8, 2016 at 2:41 PM, Taher Alkhateeb <
> slidingfilame...@gmail.com>
> wrote:
>
> > Hello Everyone,
> >
> > After refactoring the start component and while starting on the base
> > component I realized that the testing framework for OFBiz is not good.
> You
> > cannot do real test driven development or red-green-refactor with the
> > current setup, hence my proposal to change it. I explain below:
> >
> > Problem with current design
> > ----------------------------------------
> > - What we have right now is not unit tests, it's really integration
> tests.
> > You have to start the framework, the database, the service engine, the
> > entity engine and pretty much everything.
> > - Testing is very slow, because it's an integration test as I mentioned
> > above. 10 minutes on a good computer!
> > - There is zero mocking! We actually have to --load-data for things to
> > work. Again, these are integration tests.
> > - Too complex: Integration tests by their nature are grabbing too much.
> > Mind you, I am not objecting to integration tests (I actually like them)
> > but I am objecting to not having real unit-tests. Unit tests should all
> run
> > in a few seconds.
> >
> > Proposed solution
> > --------------------------
> > - We keep what is considered real integration tests the way they are
> right
> > now and keep using them
> > - We move what should be unit tests into simple JUnit classes, and we do
> > not run them using java -jar ofbiz.jar --test, but instead run them
> > directly from the build.xml script, so these files are not identified in
> > any XML document, but are simply called immediately from the build
> scripts.
> > - We clearly mark the difference between integration tests and unit tests
> > (inside the source files or in the suite declarations).
> > - We change the run-tests target in build.xml to run both unit tests and
> > integration tests.
> >
> > I intend to heavily refactor the framework and I would feel better about
> > introducing this change while refactoring. What do you guys think? Ideas?
> > Suggestions? Approvals and thumbs up?
> >
> > Regards,
> >
> > Taher Alkhateeb
> >
>

Reply via email to