How to run cucumber feature file from java code not from JUnit Runner

后端 未结 2 1463
挽巷
挽巷 2020-12-06 20:00

I want to run cucumber feature file from java code.

currently we are running form JUnit Runner

package com.compareglobalgroup.testscript;

import cuc         


        
2条回答
  •  旧时难觅i
    2020-12-06 21:01

    Call the static main method of Main class in the package cucumber.api.cli that corresponds to running cucumber from the command line.

    public static void main(String[] args) throws Throwable {
    
        Main.main(new String[]{"-g", "classpath to step definition file", "Full path to feature file"});
    
              // My stepdefinition is inside java package at cucumber.sample.test
              // My feature file is inside src/test/resources/features/featurefile.feature
    
            } 
    

    For additional parameters like tags or plugin use "-t","@Tags". Important the feature file path has to be the last option.

    BTW - In the your example you are running with a TestNG cucumber runner.

提交回复
热议问题