Skip to content

Instantly share code, notes, and snippets.

@judoole
Created October 7, 2011 13:24
Show Gist options
  • Save judoole/1270262 to your computer and use it in GitHub Desktop.
Save judoole/1270262 to your computer and use it in GitHub Desktop.
GroovyBDDJUnitShit
@Test
public void skal_hente_alle_tenant_profiler() {
Gitt.at_tenant_profile_eksisterer(new TenantProfile(1, "Single"))
Gitt.at_tenant_profile_eksisterer([id:2, description:"Dubletter"])
Gitt.at_tenant_profile_eksisterer(new TenantProfile(id:3, description:"Tribletter"))
Naar.jeg_henter_informasjon_om_soknadslista()
Saa.skal_antallet_tenant_profiler_vaere(3)
}
@Autowired
private GodAndOdinStep Gitt;
@Autowired
private GodAndOdinStep Naar;
@Autowired
private GodAndOdinStep Saa;
@follesoe
Copy link

Minner om en hjelpeklasse jeg bruker en gang i blant (BDD støtte på 7 kodelinjer).

public abstract class BDD<T> where T : BDD<T>
{
    protected T Given { get { return (T)this; } }
    protected T When { get { return (T)this; } }
    protected T Then { get { return (T)this; } }
    protected T And { get { return (T)this; } }    
}

Og her en annen variant:

[TestFixture]
public abstract class SpecFor<T>
{
    protected T Subject;

    [SetUp]
    public void Setup()
    {
        Subject = Given();    
        When();
    }

    protected abstract T Given();
    protected abstract void When();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment