jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Russell <gra...@ham1.co.uk>
Subject Re: Mocking Framework
Date Sat, 14 Jan 2017 21:47:05 GMT
Felix/all

1. I've reverted the move - it was intended to make compilation simpler,
but it isn't required.

2. Thanks for the pointer - I've edited AllTests to find Spock
Specifications.

3. I've added a few more examples, I've used Mocks in a few places.

The main tests of interest are in org.apache.jmeter.engine.util:
PackageTest has gone from 234 to 107 lines in PackageSpec by using "where:"
and HTTPUtilsSpec is also much easier to read/edit/add to.

I've edited the base JMeterTestCases to work when run from IntelliJ (and
created a similar base JMeterSpec).
I've also fixed tests which failed when adding the Spock library e.g.
eclipse.classpath and LICENSE file.

Are there any tests for which you think mocking would be especially useful
and easy i.e. without having to refactor a lot of code?

I'm not sure about my changes to build.xml, especially the compilation of
tests.
Please have a look at: https://github.com/ham1/jmeter/commits/spock
and let me know thoughts/feedback and what needs to be done next.

If we do move to Spock I'd like to help increase the test coverage and
improve readability of the current tests.

Thanks

Graham

P.S. Sorry for the extra whitespace fixes/changes, it's just a habit - I
could remove it and squash commits if that would help reviewing?

On 12 January 2017 at 20:11, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:
> Am 12.01.2017 um 19:47 schrieb Graham Russell:
>>
>> Hi all
>>
>> I've created a branch on github where I've started using Spock -
>> https://github.com/ham1/jmeter/tree/spock - I can create a PR if that's
>> more useful.
>
> For now that is fine.
>
> Why did you move the test src from test/src to test/src/java? Is it needed
> by spock?
>
>>
>> Test compilation works with ant and I can run tests run via my IDE
>> (IntelliJ), however, I haven't yet been able to figure out how to run
>> these
>> as part of `ant test`.
>
> ant test looks for classes, that can be assigned to TestCase or have junit
> annotations. Do spock classes come with those?
>
>>
>> Does someone, with more experience of ant, have some time to look at the
>> code and help get it fully working?
>>
>> I've created two tests, one which replicates an existing test and one for
>> a
>> new class.
>>
>> I really like Spock's given/when/then test structure and built-in
>> Mock/Spy/Stubs.
>> It is also possible to mock static Java methods with Spock and PowerMock
>> (see: https://dzone.com/articles/mocking-static-methods-groovy).
>
> I think it would be nice to have a few more cases, where we can see
mocking
> and such and the nice tabular data parameters for tests.
>
> Thanks for your contribution so far.
>  Felix
>
>
>>
>> Thanks
>>
>> Graham
>>
>> On 19 December 2016 at 11:47, Felix Schumacher <
>> felix.schumacher@internetallee.de> wrote:
>>>
>>> Am 18.12.2016 um 15:46 schrieb Graham Russell:
>>>>
>>>> Felix
>>>>
>>>> I really like using spock.
>>>>
>>>> I'm not sure how to get it working with ant, but I'm sure it's doable.
I
>>>> should have some time in the new year to try adding some spock tests if
>>>> that's useful?
>>>
>>> That would be great.
>>>
>>>> Please see:
>>>> https://mechanitis.blogspot.com/2013/12/spock-data-driven-testing.html
>>
>> and
>>>>
>>>> the two other posts in that series (not my blog) for some of the
reasons
>>
>> I
>>>>
>>>> like it.
>>>
>>>
>>> Will have a look, thanks.
>>>
>>>   Felix
>>>
>>>> Thanks
>>>>
>>>> Graham
>>>>
>>>> On Sun, 18 Dec 2016, 20:30 Felix Schumacher, <
>>>> felix.schumacher@internetallee.de> wrote:
>>>>
>>>>> Am Dienstag, den 13.12.2016, 22:36 +0100 schrieb Philippe Mouawad:
>>>>>>
>>>>>> On Sunday, December 11, 2016, Felix Schumacher <
>>>>>> felix.schumacher@internetallee.de> wrote:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> Philippe has brought up the potential usage of a mocking framework
>>>>>>> in
>>>>>>> another thread. That is something I too would like to see used
in
>>>>>>> our
>>>>>>> tests. He has linked mockito 2 as a candidate. I think a strong
>>>>>>> contender
>>>>>>> would be jmockit (http://jmockit.org/) or (additionally) something
>>>>>>> like
>>>>>>> spock (http://spockframework.org/).
>>>>>>>
>>>>>>> What do you think?
>>>>>>
>>>>>> I have a little experience with mockito2, not with other, so it's
>>>>>> hard to
>>>>>> answer.
>>>>>> Some elements that might be useful:
>>>>>>
>>>>>>      - https://www.openhub.net/p/spock
>>>>>>      - https://www.openhub.net/p/jmockit
>>>>>>      - https://www.openhub.net/p/mockito
>>>>>>
>>>>>>
>>>>>> Maybe we should take a place where we want to introduce it and make
>>>>>> an
>>>>>> example with the 2 or 3 implementations to give us some ideas
>>>>>
>>>>> Now that builds.apache.org/analysis includes jmeter stats, we can see,
>>>>> that jdbc needs a few more tests :) So I think it would be a good idea
>>>>> to test mockito and jmockit on some jdbc test elements.
>>>>>
>>>>> I haven't used spock before, so I don't really know, what we would
have
>>>>> to do in order to use it.
>>>>>
>>>>> I will open a bug enhancement to add a mocking framework. We could add
>>>>> patches there, or add PR to it.
>>>>>
>>>>> Regards,
>>>>>    Felix
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Felix
>>>>>>>
>>>>>>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message