Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 81434200BFC for ; Sat, 14 Jan 2017 22:47:42 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7E784160B35; Sat, 14 Jan 2017 21:47:42 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A4D58160B2D for ; Sat, 14 Jan 2017 22:47:41 +0100 (CET) Received: (qmail 27476 invoked by uid 500); 14 Jan 2017 21:47:40 -0000 Mailing-List: contact dev-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list dev@jmeter.apache.org Received: (qmail 27465 invoked by uid 99); 14 Jan 2017 21:47:40 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Jan 2017 21:47:40 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 2EFA1C0221 for ; Sat, 14 Jan 2017 21:47:40 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 6.099 X-Spam-Level: ****** X-Spam-Status: No, score=6.099 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_COUK=1.1, RDNS_NONE=3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 6UIp8m3n31pR for ; Sat, 14 Jan 2017 21:47:37 +0000 (UTC) Received: from ham1.co.uk (unknown [178.62.53.111]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id D69D95F29A for ; Sat, 14 Jan 2017 21:47:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ham1.co.uk (Postfix) with ESMTP id BBB21401EB for ; Sat, 14 Jan 2017 21:47:27 +0000 (GMT) Received: from ham1.co.uk ([127.0.0.1]) by localhost (ham1.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gd3EGzZ6CPze for ; Sat, 14 Jan 2017 21:47:16 +0000 (GMT) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mysmtpaccount) by ham1.co.uk (Postfix) with ESMTPSA id 1BF1C4018D for ; Sat, 14 Jan 2017 21:47:16 +0000 (GMT) Received: by mail-wm0-f48.google.com with SMTP id c85so110197053wmi.1 for ; Sat, 14 Jan 2017 13:47:16 -0800 (PST) X-Gm-Message-State: AIkVDXJV/jzM26LCJjUbCs3YRQFxJCXKlFWBPmkRnO8XH7F4RO+CH9k3rXaeqj83uw9Dy2kqMDmozxc5I0cp4Q== X-Received: by 10.223.162.206 with SMTP id t14mr20132652wra.42.1484430435811; Sat, 14 Jan 2017 13:47:15 -0800 (PST) MIME-Version: 1.0 References: <36ce3782-dee8-388c-9539-5bcfb8d5f39a@internetallee.de> <1482064181.6850.21.camel@internetallee.de> <76acc846-6a06-292c-c752-bff858835792@internetallee.de> In-Reply-To: From: Graham Russell Date: Sat, 14 Jan 2017 21:47:05 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Mocking Framework To: dev@jmeter.apache.org Content-Type: multipart/alternative; boundary=f403045ea118d208ad054614e440 archived-at: Sat, 14 Jan 2017 21:47:42 -0000 --f403045ea118d208ad054614e440 Content-Type: text/plain; charset=UTF-8 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 >>>>>>> >>>>>>> > --f403045ea118d208ad054614e440--