Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

cucumber - In the Karate DSL Framework, how can we add custom step definitions to expand its functionalities beyond REST capabilities?

I understand the philosophy behind Karate is to not have to add custom Step definitions. However, the REST API Testing we perform in our project is more integrated so we have to verify POST responses in MongoDB collections, ActiveMQ, and a SQL Server DB. Is there anyway to easily add custom step definitions to expand the Karate DSL Framework beyond its REST Capabilities? I tried downloading the source code and importing it as a Maven project but I came across many dependency issues.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is very easy to extend Karate via Java Interop. The best way to understand this, is to look at this demo example which uses JDBC to call a database: dogs.feature.

It is worth calling out here that if you return a Map (or List of Maps) from Java - you are back in JSON-land within Karate, and you can use match and all the other data-driven goodness of Karate.

Yes, it is that easy - and you don't have the un-necessary overhead of Step Definitions and dependency injection.

Hope this makes it clear as to why you don't need step definitions at all !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...