Home > Mobile >  How does Karate start up application in Azure pipeline?
How does Karate start up application in Azure pipeline?

Time:02-21

I have followed How to Run Karate API tests on Azure pipelines to set up karate on azure pipeline.

We need to first start up the application in order to run karate tests.

  1. Imagine I have a dev api publicly available and I have some new changes to merge in.

    It still doesn’t make sense to test on this dev environment because the new karate test cases on the new features are not yet available on dev and of course the karate tests will fail.

  2. If we look at example projects they all excluded the karate test files. What is the reason to exclude them? Shouldn't we include them instead so the karate test run during pipeline?

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
            <excludes>
                <exclude>karate/**/*.java</exclude>
            </excludes>
            <includes>
                <include>com/**/*.java</include>
            </includes>
        </configuration>
    </plugin>
    

CodePudding user response:

you can use maven command in azure to run karate test as I understood your requirement correctly.

But if you need to different steps for building application and running test, you need to have two step in the pipeline in order, like creating bash script or something similar. Maybe you can use Makefile and make command to build and run your test, like;

build-and-run:
     mvn (run app command) && mvn clean test -Dtest=myRunner

Currently I am using azure devops for running some karate tests but my tests doesn't required to have make application since they are run against staging env. I used this step for running karate test:

    - task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'clean test -Dusername=$(USERNAME) -Dpassword=$(PASSWORD)'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    mavenVersionOption: 'Default'
    mavenOptions: '-Xmx3072m'
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: false

This is autogenerated by azure devops, I just put my run command

CodePudding user response:

Well.. none of you were able to mention the maven failsafe plugin which were designed to run integration test.

First start up the enviornment with spring-boot-maven-plugin

This will start up your spring application in the azure hosted agent to run the karate test.

Karete documentation did a good job explaining how to change the enviornment in karate config.js. But didn't mention anything what enviornment should we use in pipeline

  • Related