You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Graham Russell <gr...@ham1.co.uk> on 2017/11/19 11:28:28 UTC

Re: Mocking Framework

Hi all

I've resurrected the Spock branch (https://github.com/apache/jmeter/pull/332)
does anyone have any thoughts on this thread?
Does this need a vote, some more work or discussion?
Is there a test which I should try to re-write in Spock to make sure it can
do what we need?
Unfortunately a lot of the code hasn't been written with testability in
mind, so mocking etc. is difficult without refactoring.
I really think this will help improve unit test coverage in JMeter by
making it easier (and more fun) to test.

If you had some time please read http://spockframework.org/spock/docs/1.0/
alongside the tests I've created, it has more detail about Mock/Spy/Stubs
in Spock.

Thanks

Graham

On Sun, 22 Jan 2017 at 12:43 Graham Russell <gr...@ham1.co.uk> wrote:
>
> I've added a few more tests which make more use of mocks and I've
refactored AbstractJDBCTestElement a little: https://github.com/ham1/jmeter
/commits/spock
>
> One of the nice things about testing with groovy is that you can test
protected and private methods/classes without having to use reflection or
change access.
>
> Does anyone have any questions/concerns/thoughts on the code so far with
Spock?
>
> What needs to be done next to agree (or not) the move to Spock?
>
> Many thanks
>
> Graham
>
> On Sat, 14 Jan 2017, 21:47 Graham Russell, <gr...@ham1.co.uk> wrote:
>>
>> 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?