afoltin / garnishtest Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
We should support multiple HTTP clients.
This will allow us to call multiple APIs in the tests, potentially each API having its own authentication scheme.
To integrate this seamlessly:
defaultHttpClient
defaultHttpClient
, e.g. When I call GET on '/my/api'
. These steps will make the tests more readable when you don't need multiple HTTP clients.When I call GET on '/my/api' using 'myApiClient'
Currently we only support one database client for the DB steps.
Sometimes we need to work with more that one DB at once. For example, it may be that calling a REST client will create entries in 2 DBs and we need to verify both.
To integrate this seamlessly:
defaultRdbmsClient
defaultRdbmsClient
, e.g. Then the database state should be like in 'expected.db.xml'
. These steps will make the tests more readable when you don't need multiple RDBMS clientsThen the database state should be like in 'expected.db.xml', using 'myRdbmsClient'
This will:
to make it easy to start using the framework
Integrate http://www.icegreen.com/greenmail/ in a email mock server module.
Add demo.
There can be many combinations of headers, body, etc. when composing a request:
The current approach is to have a step for each combination. This leads to an explosion in the number of required steps.
Refactor to allow the request to be composed using multiple steps:
Given the request headers
| Content-Type | application/x-www-form-urlencoded |
And the form body parameters
| grant_type | password |
| client_id | com.farbodsaraf |
When I call 'POST' on '/authserver/oauth/token'
This way, you can compose whatever request is needed, and the code remains maintainable.
The intermediary information (headers, body, etc.) can be saved in story variables.
Important note: the steps that perform the actual request should clear all such story variables, so that another request in the same scenario will not be affected.
Something like this #1 :
@given("^the grppy request headers$")
public void the_request_headers(@nonnull final Map<String, String> requestHeaders) {
PREPARED_HEADERS.setValue(requestHeaders);
}
@When("^I call '(POST|PUT|PATCH)' on '(.+)' with JSON from '(.+)' and previously provided headers$")
public void callMethodOnUrlWithJsonBodyAndHeaders(
@NonNull final HttpMethod method,
@NonNull final String url,
@NonNull final String jsonReqBodyFile
) {
String jsonBody = ClasspathUtils.loadFromClasspath(ResourceFilesVariables.getResourceFilesPrefix() + jsonReqBodyFile);
jsonBody = ScenarioUserVariables.resolveInText(jsonBody, ValueEscapers.json());
jsonBody = JsonUtils.makeValidJson(jsonBody);
HttpRequestBuilder requestBuilder = this.httpClient.request(method, url);
final Map<String, String> requestHeaders = PREPARED_HEADERS.getValue();
if (requestHeaders != null) {
for (final Map.Entry<String, String> entry : requestHeaders.entrySet()) {
requestBuilder = requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
requestBuilder = requestBuilder.body(jsonBody, ContentType.APPLICATION_JSON);
HttpResponse response = requestBuilder.execute();
this.responseManager.setResponse(response);
}
[ERROR] Failed to execute goal com.mobiquityinc.mobit:cucumber-reports-maven-plugin:0.16:generate-reports (generate-cucumber-reports) on project presentation-test: failed to create directory [/Users/alfred/work/BCC/Rabobank-Moonshot/presentation/presentation-test/target/cucumber/cucumber-html-report] or one of its parents -> [Help 1]
The poms:
Make it obvious that the project is licensed under Apache 2.0:
Currently it gives an error "org.dbunit.dataset.NoSuchTableException: USERS"
Looks like @isnotempty() and @matchesRegex() are not working for Json assertions? Could you add some working examples?
HttpMocksSteps.given_http_mocks_from_classpath_resource does not de-serialize header information for mock responses.
I got this to work using wiremock 2.5.0
and the following code (no prizes for elegance here):
@given("^http grppy mocks from '(.+)'$")
public void given_http_mocks_from_classpath_resource(@nonnull String httpMocksFile) throws JSONException {
if (httpMocksFile == null) {
throw new IllegalArgumentException("httpMocksFile is null");
} else {
String serializedMappings = ClasspathUtils.loadFromClasspath(ResourceFilesVariables.getResourceFilesPrefix() + httpMocksFile);
List mappings = new ArrayList<>();
JSONArray jsonArray = new JSONArray(serializedMappings);
for (int i = 0; i < jsonArray.length(); i++) {
mappings.add(StubMapping.buildFrom(jsonArray.getJSONObject(i).toString()));
}
this.httpMockServerManager.reset();
this.httpMockServerManager.register(mappings);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.