reportportal / agent-java-karate

Karate integration for ReportPortal
Apache License 2.0
10 stars 16 forks source link

Integrate Karate V0.9.6 with reportportal #11

Closed ajij-shaikh closed 7 months ago

ajij-shaikh commented 3 years ago

Hey, can we have the integration of the karate V0.9.6 with the report portal?

kirksl commented 3 years ago

@ajij-shaikh maybe this will work for you as there is not an agent that works right now.

https://github.com/kirksl/karate-maven-gradle

for 0.9.6 support... git checkout a770a9361396a249456a3f2d5b59ff0a8fab9481

ajij-shaikh commented 3 years ago

@kirksl thanks for your help! I am trying to run the test by starting the spring boot server with the command -

  1. mvn clean test -Dtest=KarateRunner -Dreportportal=true
  2. mvn clean test -Dreportportal=true

on the above code with the valid report portal configuration but not getting the data in the report portal I am getting other reports such as JUnit, cucumber in the repo

kirksl commented 3 years ago

@ajij-shaikh apologies. the readme is a little confusing. you have to checkout the commit and follow the older readme.md.

let me know if these steps still don't work for you

  1. git checkout a770a9361396a249456a3f2d5b59ff0a8fab9481
  2. follow steps in this commits readme to enable reportportal
  3. uncomment this basically https://github.com/kirksl/karate-maven-gradle/blob/a770a9361396a249456a3f2d5b59ff0a8fab9481/src/test/java/KarateRunner.java#L20
  4. mvn clean test -Dtest=KarateRunner
ajij-shaikh commented 3 years ago

@kirksl works like a charm! :+1: awesome work dude. As I using maven will it be ok if I delete Gradle-related files? Also, this codebase will be usable for karate new version 1.0.1?

kirksl commented 3 years ago

@ajij-shaikh nice glad it worked. yep blow away gradle then this is just a demo project setup with multiple build systems. git checkout master if you want to use karate 1.0+. had to change a lot but should work too...

deepsmittal commented 3 years ago

@kirksl When i do git checkout mentioned in above, got following error:

fatal: reference is not a tree: a770a9361396a249456a3f2d5b59ff0a8fab9481

Also i am trying out running report portal with karate 1.0.1 but it is not working out , however i am getting also cucumber, Junit .

kirksl commented 3 years ago

@deepsmittal is this what you were trying to do?

C:\git\test>git clone https://github.com/kirksl/karate-maven-gradle.git
Cloning into 'karate-maven-gradle'...
remote: Enumerating objects: 211, done.
remote: Counting objects: 100% (211/211), done.
remote: Compressing objects: 100% (149/149), done.
Receiving objects:  81% (171/211)sed 152 (delta 44), pack-reused 0 eceiving objects:  58% (123/211)
Receiving objects: 100% (211/211), 106.97 KiB | 1.78 MiB/s, done.
Resolving deltas: 100% (91/91), done.

C:\git\test>cd karate-maven-gradle

C:\git\test\karate-maven-gradle>git checkout a770a9361396a249456a3f2d5b59ff0a8fab9481
Note: switching to 'a770a9361396a249456a3f2d5b59ff0a8fab9481'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at a770a93 java 11 support, default to maven/gradle wrappers, default to auto run without prompting

C:\git\test\karate-maven-gradle>git branch
* (HEAD detached at a770a93)
  master
Shivin89 commented 2 years ago

Update: I was successful in sending tests results to Report Portal (I had to use the JKS file ), but for my own project error stills comes for var

HI, @kirksl I am not able to see results in Report Portal .

I followed the process of Cloning the master branch (Karate 1.0.1) and did mvn clean test -Dreportportal=true The test is running (error) but I don't see results in Report Portal.

I provided the Report portal settings in the file

For My own project (Added the screenshot)

I added KarateHook, RP Reporter files to my own project (Maven project ), and for KarateRunner (I have a similar runner class for my project and in that, I tried adding
Boolean rp = Boolean.parseBoolean(System.getProperty("reportportal", "false")); var rb = Runner.builder(); ( Var is not getting resolved and if I import it imports from lombok) if (rp) { rb.hook(new KarateHook()); }

@Test public void testParallelDesktop() { Boolean rp = Boolean.parseBoolean(System.getProperty("reportportal", "false")); var rb = Runner.builder(); ( Var is not getting resolved and if I import it imports from lombok) Results results = rb.path("classpath:com") .outputCucumberJson(true) .tags("@PostF&I") .parallel(0); if (rp) { rb.hook(new KarateHook()); } generateReport(results.getReportDir());

    assertTrue(results.getFailCount() == 0, results.getErrorMessages());
     }

image

My POM file

<?xml version="1.0" encoding="UTF-8"?> <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">

4.0.0
<groupId>org.example</groupId>
<artifactId>Roadster_POC</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <maven.compiler.version>3.8.1</maven.compiler.version>
    <maven.surefire.version>2.22.2</maven.surefire.version>
    <karate.version>1.1.0</karate.version>
    <extentreport.version>5.0.4</extentreport.version>
    <spring.boot.version>1.5.22.RELEASE</spring.boot.version>

</properties>

<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>bintray-epam-reportportal</id>
        <name>bintray</name>
        <url>http://dl.bintray.com/epam/reportportal</url>
    </repository>
</repositories>

<dependencies>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>${spring.boot.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>${spring.boot.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>junit-vintage-engine</artifactId>
                <groupId>org.junit.vintage</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.epam.reportportal</groupId>
        <artifactId>commons-model</artifactId>
        <version>5.0.0</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.2.3</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-access</artifactId>
        <version>1.2.3</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback.contrib</groupId>
        <artifactId>logback-json-classic</artifactId>
        <version>0.1.5</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback.contrib</groupId>
        <artifactId>logback-jackson</artifactId>
        <version>0.1.5</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.12.1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.12.1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.12.1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>net.logstash.logback</groupId>
        <artifactId>logstash-logback-encoder</artifactId>
        <version>4.9</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.18</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.epam.reportportal</groupId>
        <artifactId>logger-java-logback</artifactId>
        <version>5.0.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-mock-servlet</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-gatling</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-robot</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit5</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>${extentreport.version}</version>
    </dependency>
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>3.8.0</version>
        <scope>test</scope>
    </dependency>
  <!--  <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>-->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.7.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <testResources>
        <testResource>
            <directory>src/test/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </testResource>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>
    <plugins>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring.boot.version}</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.version}</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <compilerArgument>-Werror</compilerArgument>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.version}</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <argLine>-Dfile.encoding=UTF-8</argLine>
                <includes>
                    <include>**/KarateRunner.java</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

How can I resolve this issue? Can't we use Plugins in our test runner? and if I want to run through driver runner (How can I use the report portal argument )

deepsmittal commented 2 years ago

@kirksl When i tried the solution mentioned in master for reportPortal, It is throwing following error :

com.epam.reportportal.exception.InternalReportPortalClientException: Base url for Report Portal server is not set!

Could you please help on this.

kirksl commented 2 years ago

@deepsmittal can you confirm if you've followed these steps in the readme

to enable for karate 1.0:

deepsmittal commented 2 years ago

@deepsmittal can you confirm if you've followed these steps in the readme

to enable for karate 1.0:

  • install report portal from https://reportportal.io/
  • update /src/test/resources/reportportal.properties
  • specify jvm arg "-Dreportportal=true" in above commands

Yes @kirksl , i have followed the steps mentioned above.

kirksl commented 2 years ago

@deepsmittal i just pulled the project down from master branch, updated both files in the image attached below and ran the command you see in the console and it worked for me. please try and if you still have trouble please let me know. it sounds like your reportportal is not setup correct in settings possibly.

image

Shivin89 commented 2 years ago

Hi Kirk,

Did you see the issue I created recently? Any thoughts on it ?

Multiple Scenarios in QARP If we call a Scenario in another Feature #14

Thanks Shivin Saraf

On Wed, Feb 9, 2022 at 10:18 AM Kirk Slota @.***> wrote:

@deepsmittal https://github.com/deepsmittal i just pulled the project down from master branch, updated both files in the image attached below and ran the command you see in the console and it worked for me. please try and if you still have trouble please let me know. it sounds like your reportportal is not setup correct in settings possibly.

[image: image] https://user-images.githubusercontent.com/24948266/153264561-8b31c048-6938-4954-8456-fb09b296bddd.png

— Reply to this email directly, view it on GitHub https://github.com/reportportal/agent-java-karate/issues/11#issuecomment-1034059310, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFK5BSTMX6QYUGPBK2BGLLTU2KVYNANCNFSM4256DUNQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

deepsmittal commented 2 years ago

@deepsmittal i just pulled the project down from master branch, updated both files in the image attached below and ran the command you see in the console and it worked for me. please try and if you still have trouble please let me know. it sounds like your reportportal is not setup correct in settings possibly.

image

Hi @kirksl ,

This worked even for me when i moved reportportal.properties from resources to src/test/java. Thanks for all inputs.

abhishekagc966gmailcom commented 9 months ago

Hi @kirksl , I am trying to integrate the reportportal with my karate project, Here are the steps that I have followed till now. I have copied KarateHook.java, KarateRunner.java, RPReporter.java in sr/test/java and also created the reportportal.properties file and updated the credentials there, But When I try to run it It is giving the issue in KarateRunner.java, cannot find symbol symbol: class var location: class KarateRunner Here you have used var in java file file which is causing the issue,But I don't know what should be the return type there, How to resolve this or what am I doing wrong here?

kirksl commented 9 months ago

@abhishekagc966gmailcom can you confirm what version of Java you are using. The keyword var for local type inference was not available until Java 10.

abhishekagc966gmailcom commented 9 months ago

@kirksl , Currently I am using java 8.

HardNorth commented 7 months ago

Please use karate of version 1.3.1 and newer. Earlier versions of Karate are not planned for support.