forked from TNG/JGiven
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend @as with a provider mechanism.
This change extends the @as annotation for step / stage methods and classes with an AsProvider provider() method to allow a more flexible way of customizing the result. fixes TNG#189
- Loading branch information
Showing
6 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
jgiven-core/src/main/java/com/tngtech/jgiven/annotation/AsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.tngtech.jgiven.annotation; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* TODO | ||
* @since 0.12.0 | ||
*/ | ||
public interface AsProvider { | ||
|
||
/** | ||
* TODO | ||
* @since 0.12.0 | ||
*/ | ||
String as( As annotation, Method method ); | ||
|
||
/** | ||
* TODO | ||
* @since 0.12.0 | ||
*/ | ||
String as( As annotation, Class<?> scenarioClass ); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
jgiven-core/src/main/java/com/tngtech/jgiven/impl/params/DefaultAsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.tngtech.jgiven.impl.params; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import com.tngtech.jgiven.annotation.As; | ||
import com.tngtech.jgiven.annotation.AsProvider; | ||
|
||
/** | ||
* TODO | ||
* | ||
*/ | ||
public class DefaultAsProvider implements AsProvider { | ||
|
||
@Override | ||
public String as( As annotation, Method method ) { | ||
return annotation.value(); | ||
} | ||
|
||
@Override | ||
public String as( As annotation, Class<?> scenarioClass ) { | ||
return annotation.value(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters