Gwen

Library for specifying acceptance criteria in tests in a Given-When-Then format

License

License

GroupId

GroupId

com.shazam
ArtifactId

ArtifactId

gwen
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Gwen
Library for specifying acceptance criteria in tests in a Given-When-Then format
Project URL

Project URL

http://github.com/shazam/gwen
Source Code Management

Source Code Management

http://github.com/shazam/gwen

Download gwen

How to add to project

<!-- https://jarcasting.com/artifacts/com.shazam/gwen/ -->
<dependency>
    <groupId>com.shazam</groupId>
    <artifactId>gwen</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.shazam/gwen/
implementation 'com.shazam:gwen:1.0.2'
// https://jarcasting.com/artifacts/com.shazam/gwen/
implementation ("com.shazam:gwen:1.0.2")
'com.shazam:gwen:jar:1.0.2'
<dependency org="com.shazam" name="gwen" rev="1.0.2">
  <artifact name="gwen" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.shazam', module='gwen', version='1.0.2')
)
libraryDependencies += "com.shazam" % "gwen" % "1.0.2"
[com.shazam/gwen "1.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Gwen

Gwen is a simple library that allows writing acceptance tests in a Given-When-Then syntax.

Using Gwen, we can transform a very verbose and implementation specific test like this:

public void testNotGonnaTellYou() {
    final Instrumentation instrumentation = getInstrumentation();
    final Context targetContext = instrumentation.getTargetContext();
 
    File cacheDir = targetContext.getCacheDir();
    try {
        File file1 = File.createTempFile("file1", "txt", cacheDir);
        File file2 = File.createTempFile("file2", "txt", cacheDir);
    } catch (IOException e) {
        e.printStackTrace();
        Assert.fail("Failed to create files " + e.getMessage());
    }
 
    Intent intent = new Intent(targetContext, DirectoryBrowserActivity.class);
    intent.setData(Uri.parse(cacheDir.getAbsolutePath()));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    targetContext.startActivity(intent);
 
    final Solo solo = new Solo(instrumentation);
    final boolean file1Displayed = solo.searchText("file1.txt");
    final boolean file2Displayed = solo.searchText("file2.txt");
    if (!file1Displayed || !file2Displayed) {
        Assert.fail("Activity did not display files");
    }
}

into a readable, reusable, extensible and maintainable test like this:

public void testDisplaysDirectoryContents() {
    given(directory).contains(SOME_FILES);
     
    when(user).isViewing(directory);
     
    then(user).canSee(THESE_FILES);
}

License

Apache v2.0

com.shazam

Shazam

Versions

Version
1.0.2