isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian K <harvestmoon...@gmail.com>
Subject Re: BDD Testing MessageService
Date Tue, 11 Sep 2018 21:11:48 GMT
Thanks for the work-around!  Very helpful and reveals how easy it is to
override a domain service.  I created a StubMessageService class in the
domainapp.modules.simple.specglue package:

@DomainService(menuOrder = "1")
public class StubMessageService extends MessageServiceDefault {
   @Getter  @Setter
    private String informMessage;
    @Getter @Setter
    private String warnMessage;
    @Getter @Setter
    private String errorMessage;

    @Override
    public void informUser(String message) {
        this.setInformMessage(message);
        super.informUser(message);
    }
... // same for warnUser and raiseError methods
}

Injecting this service into my glue class, I check getInformMessage() to
see if the message was sent.

I like how Apache Isis maps out a lot of the aspects needed to work a
robust application development project.  It would be great if tests had a
MessageService available by default that you can query for feature examples
that involve user messages.  Maybe the same for the other domain services
(EmailService, audit service?).   Maybe have a higher level testing or
history service to review the service calls as command objects.

I am uncertain if I should be testing for exceptions in the spec tests, so
I'm testing for actions the application takes to handle them.  The language
to implement a Gherkin example to check for an exception seems bit odd to
me:

Given expecting an exception
When user submits form
Then expected exception is thrown

As a manual tester following this test case, I guess I'd get a net ready?

I'm thinking that testing for an expected exception might belong in a JUnit
unit or integration test, not as spec glue.  The user message or any other
action to handle the exception, on the other hand, can be described
fluently with Gherkin.

Thanks again!
Brian

On Mon, Sep 10, 2018 at 11:13 PM Dan Haywood <dan@haywood-associates.co.uk>
wrote:

> For the example that Brian gives, you are probably right, Jorg. But in
> general there needs to be a way to assert on the interaction with this
> service
>
> The best way to do this would be to configure the framework to use a mock
> service rather than the real one. I'll try to figure out a way to do that
>  As a fallback, you could easily write your own stub service that
> implements/extends MessageService.  Annotate using
> @DomainService(menuOrder="1") so that it takes priority over the default
> framework implementation.
>
> HTH a bit
>
> Dan
>
> On Tue, 11 Sep 2018, 08:06 Rade, Joerg / Kuehne + Nagel / HAM GI-DP, <
> Joerg.Rade@kuehne-nagel.com> wrote:
>
> > Hi Brian,
> >
> > you try to test against a specific error message?
> >
> > I'd say this kind of test belongs to the framework.
> >
> > If you want to validate a property value have a look at [1].
> >
> > HTH -j
> > [1] https://isis.apache.org/pages/tg/tg.html#_do_it
> >
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Brian K [mailto:harvestmoon299@gmail.com]
> > Gesendet: Montag, 10. September 2018 22:33
> > An: users@isis.apache.org
> > Betreff: BDD Testing MessageService
> >
> > If I have a Gherkin feature like:
> >
> > Given object exists
> > When object name is set to a number
> > User is notified that names can only include alpha characters
> >
> > How do I code the spec glue to check that code like the following occurs?
> > messageService.informUser("names can only include alpha characters");
> >
> > Thanks!
> > Brian
> >
> > Kühne + Nagel (AG & Co.) KG
> > Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE
> > 812773878.
> > Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Dr. Hansjörg Rodi (Vors. ),
> > Tom Ban, Martin Brinkmann, Holger Ketz, Jan-Hendrik Köstergarten,
> Nicholas
> > Minde, Lars Wedel, Matthias Weiner.
> > Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform:
> > Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745,
> > Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
> > Geschäftsleitung Region Zentral- und Osteuropa: Dr. Hansjörg Rodi
> (Vors.),
> > Tom Ban, Dominic Edmonds, Thierry Held, Uwe Hött, Richard Huhn, Holger
> > Ketz, Jan-Hendrik Köstergarten, Jan Kunze.
> >
> > Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen
> > Spediteurbedingungen 2017 (ADSp 2017). Hinweis: Die ADSp 2017 weichen in
> > Ziffer 23 hinsichtlich des Haftungshöchstbetrages für Güterschäden (§ 431
> > HGB) vom Gesetz ab, indem sie die Haftung bei multimodalen Transporten
> > unter Einschluss einer Seebeförderung und bei unbekanntem Schadenort auf
> 2
> > SZR/kg und im Übrigen die Regelhaftung von 8,33 SZR/kg zusätzlich auf
> 1,25
> > Millionen Euro je Schadenfall sowie 2,5 Millionen Euro je
> Schadenereignis,
> > mindestens aber 2 SZR/kg, beschränken. Die ADSp sind auf unserer Webseite
> > als Download erhältlich. Auf Anfrage senden wir Ihnen diese auch gerne
> zu.
> >
> --
> DISCLAIMER: This e-mail is from Haywood Associates Ltd (Registered Number
> 3525455) and it and its attachments may be confidential and are intended
> solely for the use of the individual to whom it is addressed.  Any
> unauthorised use or dissemination of this communication is strictly
> prohibited. Any information provided to Haywood Associates Ltd shall be
> retained and used in accordance with our Privacy Statement at
> http://www.haywood-associates.co.uk/privacy.  If you have received this
> communication in error, please immediately notify the sender by return
> e-mail message and delete all copies of the original communication.
>

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