-1

As I'm learning Karate Framework from https://github.com/intuit/karate#configuration

I tried the following script (variables.feature) and executed. It seems not working properly. Can anyone help on this and I have attached my project structure for your reference?

Feature: working with variables

Scenario: assigning values to the variables

Given def myVar = 'world'

Then print myVar

* def myNum = myAge

* print myNum

Attachment:

enter image description here

Getting the following message with some code snippets.

You can implement missing steps with the snippets below:

Here's my pom.xml file contents:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.syntel.apitesting</groupId>
  <artifactId>WebservicesTest</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <dependencies>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-apache</artifactId>
        <version>0.6.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit4</artifactId>
        <version>0.6.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-testng</artifactId>
        <version>0.6.2</version>
        <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <testResources>
        <testResource>
            <directory>src/test/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </testResource>
    </testResources>        
   </build>
</project>

Thanks

Karunagara
  • 389
  • 1
  • 8
  • 30
  • Even though Karate is designed for non-programmers, I think Karate is too advanced for you, sorry. I think you are not able to read documentation. For e.g `karate-config.js` is in the wrong place. maybe your `pom.xml` is wrong. you haven't mentioned WHICH feature you have tried to run and HOW. This question seems to be a duplicate of https://stackoverflow.com/q/47975372/143475 - either try harder or just switch to some other tool please. thanks. – Peter Thomas Dec 27 '17 at 10:08
  • Hi, I have done some changes in the project and attached the same in the post. I ran variables.feature file here. Please do not discourage me as I want to learn this framework. Help me. Thank You – Karunagara Dec 27 '17 at 10:42

2 Answers2

1

You haven't mentioned HOW you are running the feature, but let me take a guess, you are trying to use the Eclipse IDE support.

Can you try reading this issue and see if it helps, thanks: https://github.com/intuit/karate/issues/90

EDIT: oh my goodness, it looks like you are using Java 5 !? Please use Java 8.

EDIT2: as you said in your other answer, you just needed to use the JUnit runner.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Yes.I executed through Eclipse IDE by right clicking and Run As - Cucumber Feature. Also I have set up as mentioned in the link "Eclipse --> Preferences --> Cucumber --> User Settings" etc. – Karunagara Dec 27 '17 at 11:02
  • I don't understand why you need testng in your `pom.xml` but anyway. just edited my answer. are you really using Java 5 even though the documentation clearly says Java 8 ? Congratulations. – Peter Thomas Dec 27 '17 at 11:45
  • I removed TestNG related things from pom.xml and checked the java version. It's jdk1.8.0_73 only. Thanks. – Karunagara Dec 27 '17 at 12:10
  • please. just look at your Eclipse, it says J2SE-1.5. fix this, and everything will start working. – Peter Thomas Dec 27 '17 at 12:12
  • I have changed the "Execution Environment version as jdk1.8.0_73" and restarted the Eclipse IDE, then ran the same feature file i.e. variables.feature. Doesn't work out. Its showing as "You can implement missing steps with the snippets below:" with some code snippets. Help me what else I can do...I'm able to attach the screenshot from comment dialog. – Karunagara Dec 27 '17 at 12:26
  • pretty sure you haven't been able to fix Eclipse, I've no idea what you mean by "Execution Environment version as jdk1.8.0_73". here's my last suggestion, 1) use the archetype, 2) run a test from the command-line (refer to the doc). best of luck (you really need it :) – Peter Thomas Dec 27 '17 at 12:30
  • I changed the Java version from Java Build Path -> JRE System Library -> Edit -> Execution Environment. – Karunagara Dec 27 '17 at 12:46
1

Finally, I got the result and able to see the proper response. Earlier I was using to execute variable.feature file as I said Right Click -> Run As -> Cucumber Features which is wrong. Go to the TestRunner.java file and then Right Click -> Run As -> JUnit Test.

Karunagara
  • 389
  • 1
  • 8
  • 30
  • this is what I suggested here: https://stackoverflow.com/a/47977192/143475 - but looks like you have some reading comprehension issues. apologies if I am sounding rude, but you have wasted both of our time. anyway, glad you got it working. please be more carefully in future and READ CAREFULLY – Peter Thomas Dec 27 '17 at 13:14