Created
June 17, 2019 01:20
-
-
Save bcarun/761478780014c7a9c5827a320cf7c14e to your computer and use it in GitHub Desktop.
Class to make Cucumber use Spring Context for test scenario execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.arun.cucumber.hello.bdd; | |
import com.arun.cucumber.hello.Application; | |
import cucumber.api.java.Before; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.boot.test.context.SpringBootContextLoader; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | |
import org.springframework.test.context.ContextConfiguration; | |
/** | |
* Class to use spring application context while running cucumber | |
*/ | |
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) | |
@ContextConfiguration(classes = Application.class, loader = SpringBootContextLoader.class) | |
public class CucumberSpringContextConfiguration { | |
private static final Logger LOG = LoggerFactory.getLogger(CucumberSpringContextConfiguration.class); | |
/** | |
* Need this method so the cucumber will recognize this class as glue and load spring context configuration | |
*/ | |
@Before | |
public void setUp() { | |
LOG.info("-------------- Spring Context Initialized For Executing Cucumber Tests --------------"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment