1

For test framework were used next stack of technologies: Java, Maven, Selenium, Junit, Cucumber, Spring Boot, YAML


Were used spring boot starter and test

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.2.4.RELEASE</version>
            <scope>test</scope>
        </dependency>

Spring boot app

package io.tpd.springbootcucumber;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@SpringBootApplication
public class SpringBootCucumberApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootCucumberApplication.class, args);
    }

}

Cucumber step definitions class - in test package

@SpringBootTest(classes = SpringBootCucumberApplication.class)
public class StepDefinitions {

    @Autowired
    private Config config;

    @Autowired
    private Environment environment;

    @Autowired
    private ScenarioContext scenarioContext;

in src/test/java directory i can autowired in every class, but in scr/main/java if i autowired my component it's null

olegMoshneaga
  • 73
  • 2
  • 7
  • Check this answer https://stackoverflow.com/questions/31399924/spring-boot-autowired-in-main-class-is-getting-null – Arthurofos Feb 19 '20 at 15:26

0 Answers0