I am using the below git repo to understand usage of pact
https://github.com/pact-foundation/pact-js/tree/master/examples/e2e
able to run successfully npm run api
but unable to see my pact file in pact broker. Am i missing anything
do we have pact maven version?
wanted to write a provider and consumer test for my api. Beyond this git repo is there step-step document which can help me create provider and consumer test in PACT-JS.
The command you've provided just runs an API, it doesn't run anything to do with Pact. As per that link, you need to run the following to run the pact tests and publish - I've copied the relevant bits here:
npm run test:consumer (from e2e directory) - Run consumer tests
npm run test:publish (from e2e directory) - Publish contracts to the broker
npm run test:provider (from e2e directory) - Run provider tests
As per the docs we have information for everything you've just talked about:
E2E example instructions: https://github.com/pact-foundation/pact-js/tree/master/examples/e2e
Step by step guide: https://github.com/pact-foundation/pact-js#tutorial-60-minutes
Pact Maven: https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven
Related
The Spring Cloud Contract docs say
"Use the REMOTE stubsMode when downloading stubs from an online repository and LOCAL for Offline work".
Why does Spring Cloud Contract stub runner need local and remote attributes?
I would expect instead that it should respect the normal Maven lifecycle... If I do a mvn clean install on the contract module it should publish locally. If I do a mvn clean deploy there, it should publish to my remote. Same for the test verifier... If there is a copy of the binaries in my local repo use that. Otherwise pull it from remote
So I am not getting why we have to include local and remote in the stub runner.
This also seems dangerous because you might accidentally check in code with local when you meant to change it to remote on the build server
Why does Spring Cloud Contract stub runner need local and remote attributes?
We've described it in the docs that you quote. When you work offline, then you want to automatically pick the stubs from your local .m2. Otherwise you want to pick it from a different location.
I would expect instead that it should respect the normal Maven lifecycle... If I do a mvn clean install on the contract module it should publish locally. If I do a mvn clean deploy there, it should publish to my remote. Same for the test verifier... If there is a copy of the binaries in my local repo use that. Otherwise pull it from remote
You're mixing stub runner with verifier. When you're on the producer side, you're using the Spring Cloud Contract verifier and it follows the maven lifecycle fully. That's because we produce a stub jar and we attach it to the standard maven flow. With Stub Runner, it's completely unrelated to your maven flow.
This also seems dangerous because you might accidentally check in code with local when you meant to change it to remote on the build server
If you check in code with local then indeed you can have a false positive. That's why you should take care of what you're doing. When you're on the consumer side and doing ./mvnw clean install/deploy then Stub Runner just follows your test setup. If in the test setup you've messed up your configuration then Stub Runner can't do much about it.
I am trying to implement gitlab CI for one of our drupal projects. For example: When a developer pushes the code to the repo in gitlab automatic tests should run using the gitlab CI pipeline which tests the code and notifies whether the code quality is fine enough to update the code to the repo. If else the developer needs to correct the coding standards and issues reported. I have tried different combination of gitlab-ci.yml file with less success.
Can anyone mention a sample gitlab-ci.yml file which can be used for drupal Projects which will trigger the CI pipeline and also run the tests using the gitlab runner so I could build upon that? I have already read through the gitlab-ci documentation.
You can start with the GitLab provided PHP template. This will get you into a docker image with PHP, xdebug, and your project composer installed.
As configured the template expects your project to have a phpunit.xml file in the root directory.
I'm running a micro service architecture with a problem on running some of the integration tests.
Running JHipster 5.0.2 on Mac against MySQL db.
LogsResourceIntTest is one example (generated by Jhipster with no modifications).
The following code aborts with a NP
this.secretKey = encoder.encodeToString(jHipsterProperties.getSecurity().getAuthentication().getJwt()
.getSecret().getBytes(StandardCharsets.UTF_8));
I have debugged it and the properties for the timeouts are set, but the token (secret) is empty.
Token is set in my /src/test/resource/application-test.yml file.
Running the test from cmd line also aborts with a NP. Running tests as follows:
./mvnw clean install -Dprofile=test
Any pointers on how to solve this problem
There's no such "test" profile in JHipster, so it can't be "generated by JHipster with no modifications". Using a profile that does not exist, you get properties from default profile.
Properties for tests are read from src/test/resources/config/application.yml because of test classpath.
Found the problem in the yml file.
Updated the file with some of my application's properties and had a format error.
I have used "test" profile" on other SpringBoot apps to help identify which files must be included for configuration. Reverted all back to default and fixed error in yml.
Will look at another way of identifying specific config files. The unit tests needs some of the Spring beans, but the integration test needs all (most of them).
Used the maven surefire and failsafe to split them before. I'm integrating to Google Pub/Sub and don't need all of that configured when doing unit tests.
Thank you for the help.
This question feels a bit strange, but here it goes:
I know I can use SCC in unit tests because I can access the stubs it creates.
But the question is, from the same stubs can I configure a standalone server that could run in some DEV server, lets say for some manual testing or for some Selenium testing of the frontend app that will ultimately use those stubs?
Have you read the docs? You can use the Stub Runner Boot application. You can read about it here https://cloud.spring.io/spring-cloud-static/Finchley.RELEASE/single/spring-cloud.html#_stub_runner_boot_application and about its Docker version here https://cloud.spring.io/spring-cloud-static/Finchley.RELEASE/single/spring-cloud.html#stubrunner-docker
UPDATE:
Updating links for Hoxton.SR1 release train (Spring Cloud Contract 2.2.1.RELEASE):
Stub Runner Boot: https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/2.2.1.RELEASE/reference/html/project-features.html#features-stub-runner-boot
Stub Runner Docker: https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/2.2.1.RELEASE/reference/html/docker-project.html
Currently I want to test the error handling of calling other micro services in consumer side via spring cloud contract. But there are some troubles blocking me to create stubs in provider side due to it's difficult to share build artifacts in docker CI build.
I'm wondering if possible to just create groovy or yaml contacts in consumer side then using them by wiremock server?
There are ways to achieve it. One, is to clone the producer's code, run ./mvnw clean install -DskipTests or ./gradlew publishToMavenLocal -x test and have the stubs installed without running any tests. Another option is to write your own StubDownloaderBuilder (for Finchley) that will fetch the contracts via Aether as the AetherStubDownloader does, but then will also automatically convert the contracts to WIreMock stubs.
Of course both approaches are "cheating". You shouldn't use the stubs in your CI system until the producer has actually published the stubs.
Maybe instead of hacking the system it's better to analyze
provider side due to it's difficult to share build artifacts in docker CI build.
and try to fix it? Why is it difficult? What exactly is the problem?