JGiven | Behavior-Driven Development in plain Java | Functional Testing library
kandi X-RAY | JGiven Summary
kandi X-RAY | JGiven Summary
JGiven is a developer-friendly and pragmatic BDD tool for Java. Developers write scenarios in plain Java using a fluent, domain-specific API, JGiven generates reports that are readable by domain experts.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Builds the formatted words .
- Search for formatting annotations .
- Find argument names .
- Wraps the given OutputStream to a ANSI OutputStream .
- Execute Mojo .
- Retrieves a map of field formatters for a given field annotation
- Print the step .
- Create config options .
- Calls the finished life cycle methods .
- Intercept the method .
JGiven Key Features
JGiven Examples and Code Snippets
Community Discussions
Trending Discussions on JGiven
QUESTION
I am quite new to JGiven and currently I have a set of REST API tests automated using Rest Assured and TestNG framework. I am also exploring JGiven as a framework to run the API tests for the advantages it gives with the human readable given when thens and the reports that it generates too. Rest Assured as a library lets us inject the URLs and actually make the REST calls. I want to understand if we have such capabilities within JGiven to actually make the REST calls. If so, I'd like to see an example and understand how I can do that. If not, can someone kindly advice and suggest the best way to achieve it with JGiven. I've been trying to search for this information but have struggled to do so thus far.
Thanks in advance.
...ANSWER
Answered 2019-Dec-01 at 11:02JGiven is useful for creating test scenarios that are understandable by domain experts. It is a general tool that can be used for any kind of testing, including testing REST APIs. JGiven adds an understandable layer on top of your underlying test infrastructure. However, you will typically need tools in addition to JGiven to implement the underlying layer. So for testing REST APIs you will use a tool like Rest Assured in combination with JGiven. With JGiven you describe your scenario in the domain language, with Rest Assured you will execute the REST calls.
QUESTION
Unfortunatly spring beans are not autowired with my approach. I used version 0.17.0 of JGiven.
The following Test fails with a NullPointerException because spring bean 'messageService' in class HelloWorldStage is null.
Gradle:
...ANSWER
Answered 2019-Jan-20 at 18:32Yes this is possible, however, it currently requires a workaround. You have to do the following two things:
- exclude jgiven-junit from jgiven-spring dependency
- create new base class SpringJunit5ScenarioTest extending both SpringExtension and JGivenExtension, also implement BeanFactoryAware to set the scenario's stage creator.
Also see https://github.com/TNG/JGiven/issues/369 for details.
The next major version of JGiven will provide Spring 5 support out of the box.
QUESTION
I'm working on a project where the domain is defined in french. I'm using JGiven to write tests and I'm trying to get the report completely in french. I'm using the Spring Test infrastructure by inheriting SpringScenarioTest
in my test classes.
Here's an example of what I did:
...ANSWER
Answered 2018-Nov-10 at 12:09Yes you can. You can have a look at the com.tngtech.jgiven.lang.de.SzenarioTestBasis
which provides this for German already. Just create a subclass of SpringScenarioTest
and define the methods that you need as follows:
QUESTION
Is there a way to change the output directory for the generated reports to an custom directory - in particular for the .json-Report files?
Documentation says (http://jgiven.org/userguide/ - 4.2):
[...] JGiven tries to autodetect when it is executed by the Maven surefire plugin [I'm using it] and in that case generates the reports into target/jgiven-reports/json. [...]
I'm using jGiven with Maven (for Appium Tests).
Configuration (pom.xml - dependencies):
...ANSWER
Answered 2017-Sep-22 at 09:27If somebody else is curious:
I found: String reportDirName = System.getProperty( JGIVEN_REPORT_DIR );
in https://github.com/TNG/JGiven/blob/fae0f3c8db0b00e7fa233cbd8f86306379def4b2/jgiven-core/src/main/java/com/tngtech/jgiven/impl/Config.java#L31 (current master).
Important part of it:
QUESTION
I am using ByteBuddy to dynamically create subclasses to add method interceptors to these classes. So far everything works, however, ByteBuddy creates final
accessor methods for every method. When I now use ByteBuddy in combination with Spring I get a ton of messages of the form
ANSWER
Answered 2017-Jan-20 at 13:03The idea of marking these methods to be final is to avoid them to be overridden by such proxies which would break their use from the proxy. At the same time, they are necessary as they contain invokespecial
calls which are not allows outside of the invoking class.
In this case, I would argue that the problem lies with Spring which should not even attempt to proxy those methods for two reasons:
- The methods are package-private; they cannot be overridden reliably even if they were not final as they are only dispatched virtually within the same class loader which is often not given for a proxy class.
- The methods are marked as synthetic, indicating an infrastructure method which should not be touched.
I would suggest to exclude such methods by default. There is very little meaning in proxying those methods.
QUESTION
Enjoying using JGiven with it's Spring support!
However, I'm having issues with @Autowired
playing nice with @BeforeScenario
in a Stage
class (annoted with @JGivenStage
. I have a minimal spring configuration (which reads a couple of property files, scans for components etc) and is denoted with @EnableJGiven
i.e.
ANSWER
Answered 2017-Jan-11 at 15:16This should be fixed in v0.14.0
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install JGiven
See the talk on JGiven held on the TNG Big TechDay
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page