Migration from 0.9.5 to 1.0.1 - ScriptBridge class equivalent - karate

We would like to move our api test created using karate framework to karate framework 1.0.1. I see that there is no such class as ScriptBridge which is used by us to attach screenshots and get information about test status, tags of currently running scenario.
What is the equivalent for the ScriptBridge class?
My question is related with Attaching screenshots to json report where I asked how to attach screenshots to report.

Short answer to your question, the class you are looking for is ScenarioBridge.
But the HTML reporting has been overhauled and hopefully you will be able to achieve what you need without hacking into internal classes. There is a somewhat undocumented doc keyword, you will find an example in the link below. If you feel helpers for handling images need to be part of Karate, do contribute or suggest a feature request.
Please read this: https://stackoverflow.com/a/66822585/143475

Related

dryRun Implementation in Karate

Just wondering if we have the dryRun functionality of cucumber in Karate ? I have gone through the information in this link - https://github.com/intuit/karate/issues/434 but it doesn't really tell me if a solution has been implemented or not. If not explicit to "dryRun" do we have a functionality within Karate that does the same operation as Cucumber ?
I have a framework and would like to know the overall count / scenarios that has been scripted and running it without the dryRun tag is a bit of an overkill
#qatestprofile
I have created Karate demo project with Dry Run example which generates HTML scenario table using Karate's Dry Run option and you can use the code as per your need.
Note: This demo example can be improved so feel free to suggest.

Karate Java API for Match methods

Background:
I noticed this interesting post on Twitter about a Java API for Karate: https://twitter.com/ptrthomas/status/1344290316212342784
I don't have a twitter account so unable to reply - hope you don't mind me asking here instead.
I have used Karate (with the parallel runner, feature files and all) in one work project and it is a joy to use - and a few folks in the workplace are very impressed with the complex JSON assertion. We are achieving a level of JSON response field coverage for that project that is not possible with other frameworks (IMO).
I've now been tasked with improving an older test project which uses JUnit + RESTAssured, but has quite limited field assertions. I am unable to fully convert it to raw Karate (too many tests, not enough time), but I'm keen to explore the possibility of supplementing what is there already with the Karate Java API mentioned in above twitter post.
For example - for an existing test which gets a Response using RESTAssured, it would be nice for me to somehow use the 'contains' method (or any of the methods in Match class) in Karate to assert that response, as it is the best JSON assertion tool I have come across.
Questions:
Off the bat - is this a practice you would recommend for my use case? Let me know if you think this is an anti-pattern. I ask this because the example here (https://github.com/ptrthomas/karate-showcase) is not using RESTAssured to get the response and my use case is a bit different.
If its worth exploring - I assume this stuff will be available in v1.0.0? (I see public methods such as that are on the develop branch, but couldn't see it on the v1.0.0 github thread).
but I'm keen to explore the possibility of supplementing what is there already with the Karate Java API mentioned in above twitter post.
That's very interesting and you have got me also thinking about this potentially interesting way to introduce Karate to legacy projects. I do get this question on how to magically migrate existing RA tests a lot.
I would recommend it. You can expect a 0.9.9.RC3 next week that should have all the assertions you want. And the API has been simplified so you don't need to call isTrue() etc.
We plan to have better examples (maybe you can help) but for now, use this as a starting point (look at the last test / very end of the file): MatchTest.java
If you want to get started now (which I recommend and you can provide more feedback) do take a look at the developer guide: https://github.com/intuit/karate/wiki/Developer-Guide

Do Karate UI support Angular UI based application testing

If karate supports Angular testing, can i have some example so that i can look into it.
Have been going through locators given at https://intuit.github.io/karate/karate-core/#locators but unable to get exact information on how to proceed.
There is no need, Karate works with plain HTML.
And if you need to do some specifc JS helpers (which is all that frameworks that claim to support Angular do), just use the tips here and make re-usable functions: https://stackoverflow.com/a/60800181/143475
If you still have a question, ask a new question and provide a sample (can be online, see examples in link above) for us to understand and discuss.

what is swagger exactly ? And why doesn't the online editor run requests?

I've spent the last few days trying to understand if I should use api blueprint, RAML or swagger.
It looks like swagger has the biggest community but the closer I look the more I feel that it greatly lacks in documentation (I was forced to look at the code many times to try and integrate it with my current project), many github issues and stackoverflow questions are unanswered.
Is it possible that I am missing something here?
All I want is a tool to help me write the API documentation and test the endpoints.
Why must swagger become part of the server logic?? If I create swagger files in the editor and then serve them to the UI directly it breaks..
As far as I can tell it even makes the server slightly slower and forces the existence of many clumsily maintained integrations :p What am I missing here?
We're trying to work a lot on improving the documentation of Swagger. It's a bit more difficult when many of the projects are community-driven and not managed by a single organization.
We actually try to reply to issues on github quickly (we don't always succeed) and we have our own google group for general questions so we follow stackoverflow somewhat less.
The editor you mention is a new tool as part of the work on Swagger 2.0 and it's not final yet. As such, it still have a few bugs and missing features. The UI is also in the process of being adapted to Swagger 2.0 and the same limitations apply to it.
You most certainly don't have to integrate it with your server and you can expose the documentation statically. The advantage of integrating it with the server is that it's easier to maintain if the API changes.
You can try RAML + ramlev + Abao
The steps should be
Write API Spec in RAML with your fav editor, ie. Atom, vim
Validate your RAML with ramlev
Implement the server logic according API Spec
Validate server logic with Abao

FluentAssertions - complete tutorial for creating custom assertions

Has anybody seen a complete tutorial for creating custom assertion classes with FluentAssertions?
Best regards
I maintain a couple of extension packages for Fluent Assertions, so feel free to take a look at our code to see how we do it:
FluentAssertions.Mvc
FluentAssertions.Ioc.Ninjet
I also recently contributed the assembly reference assertions to the core, so have a look at this pull request. Also have a look at the FA source to see how they implement similar assertions (that's where we started).
The top line is you'll need a class to hold your assertions and an extension method to hook it in.