Karate Beginner Tutorials 9 | Config File Demo | karate-config.js

preview_player
Показать описание
Today we will learn:
How to create
How to use
Multi environment testing

Can be used to
Store global variables
Configure execution environment, base URLs, Timeouts etc
Karate reads this file before executing any scenario

Step 1 - Create a new file in src/test/java
Step 3 - Create JavaScript function and add configuration

The Key Values defined in the JSON object are available to all feature files

function fn() {

var config = {
name : "test123",
}

if(env == 'qa'){
}

else if(env == 'dev'){
}

else{
}

return config;
}

No need to call, it is called by default
Must keep the file under src/test/java

The value for configurations can be passed from
TestRunner
Command Line

TestRunner Example:
@BeforeClass
public static void before() {
}

Command-line Example:
mvn test -Denv=qa

#KarateAPITesting

Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you

You can support my mission for education by sharing this knowledge and helping as many people as you can

If my work has helped you, consider helping any animal near you, in any way you can.

________ ONLINE COURSES TO LEARN ________

------------ UI TESTING ------------

------------ API TESTING ------------

------------ MOBILE TESTING ------------

------------ CI | CD | DEVOPS ------------

-------------VIRTUALISATION-------------
------------ VERSION CONTROL SYSTEM ------------

------------ PERFORMANCE TESTING ------------

------------ PROGRAMMING ------------

------------ IDE ------------

------------ BUILD TOOLS ------------

------------ OTHERS ------------

----------- Connect with Raghav ------------

Never Stop Learning
Raghav
Рекомендации по теме
Комментарии
Автор

You are explaining really amazing, Thanks for the series . Please continue the series covering, this is the bestest resource anyone could find for learning karate.

ritikagupta
Автор

When I see your video and then look at their official documentation, it looks simple and makes to learn few more concepts.
Hope you continue the series covering a few more important concepts comparing rest assured

shashibhushanv
Автор

Nice Work Raghav please continue the series and explain the advance concepts in Karate API, if possible could you please explain same using gradle aswell.

prudhvireddy
Автор

hi Sir, when im running the ConfigDemo1.feature file then its displaying below -

03:34:07.375 the value: null

And when im running the TestRunner.Java file

the value: qa

Why ? please help me here.

mayuragrawal
Автор

Muchas gracias, muy bien explicado, una duad master, se pueden colocar los headers desde el archivo de karate-config.js y llamarlos, como seria ? U_U

LaTernurin
Автор

Thanks for making this wonderful series. I will be really appreciated if you could guide me how to set the Bearer token property to run my test cases. In my project, I have enabled the security and to hit my endpoints I need to set the token.

manindersingh
Автор

Thank you for all tutorials. It would be very helpful if new tutorial can be created for karate websokets testing. Thank you!

innafirer
Автор

Thanks for sharing good series of videos. Really helpful.

dulinie
Автор

Amazing series, really clearly explained, thanks for all the efforts you put into this for our community :) also could you please send us the repo link for it? thanks!

RobertoCarlos-ymzd
Автор

hi raghave i am getting this error after creating config.js file "17:43:54.315 karate.env system property was: null
17:43:54.379
Given print name
>>>> js failed:
01: karate.log('[print]', name)
<<<<
ReferenceError: "name" is not defined
- <js>.:program(Unnamed:1)


"

anuragkasalya
Автор

Thanks you for your work and the series. My karate-config.js file is not found/read unless is it in the resources folder. I do not understant why, do you have a suggestion please ?

YannYvesLaplume
Автор

Sir can you please do vedio on schema validation

sivakesava
Автор

i run from cmd line - but system is not generating the karate-summmary.html file under target folder.

mayuragrawal
Автор

Nice Work Raghav Sir! I have a one question. May i know how i can Handle OAuth 1.0 in Karate.Thank you

mohammedrubel
Автор

Hi, I'm using gradle and junit 5, though i add karate.env in Runner I don't see any difference in the console.

meghana
Автор

Sir can we get a video to setup karate n cucumber on VSCode

hassansohail
Автор

why the function fn() said unused function ? i set up exactly like you show in the video but showing unused fn function, unsolved variable var, unsolved variable karate...ect error ?

bireylenbirsi
Автор

Hi Raghav,

Again thanks for the video. I think shorter videos would be better, but overall awesome info!

testingtrail
Автор

Easy to understand with your explanations... Good Work... One question: How were you able to get the auto suggestions in your config.js file...? is it cos of the cucumber plugin...?

mousumbhargav
Автор

Hi, i try to follow ur step in IntelJ but stuck at the the runner part, if I put the file in other folder ratehrt than src/test, it will not allow me to import the beforeClass lib, do you know hot to solve it? Thank you!

leeluke
welcome to shbcf.ru