0


I've test case structure as below. And we are triggering the TestSuite.java using maven surefire plugin on Jenkins.

        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <configuration>
                <includes>
                    <include>com/../suite/TestSuite.java</include>
                </includes>             
            </configuration>
        </plugin>

TestSuite class:

@RunWith(Suite.class)
@SuiteClasses({Test1.class, Test2.class})
public class TestSuite {
    @BeforeClass
    public static void init() {
        BaseTest.init();
    }
}

BaseTest.java{
    public static void init() throws Throwable {
        initApplicationContext();
        ...
    }

    private static void initApplicationcontext {
         String[] configLocation = { "classpath:/test-applicationContext.xml"};
         setApplicationContext(new ClassPathXmlApplicationContext(configLocation));
    }
}

Test1.java extends BaseTest{
    ...
    testMethodInBLClass1(){
        ...
        BLClass1.methodInBLClass1();
        ...
    }
}


BLClass1.java{
    methodInBLClass1(){
        BLClass2.methodInBLClass2();
    }
}

BLClass2.java{

    @Value("${some.value}")
    private String someValue;

    methodInBLClass2(){
        s.o.p(someValue);
    }
}

I've my properties file under src/test/resources, but while running the test case on Jenkins @Value is not getting injected. Thereby test case is failing.

The test cases running fine on local eclipse.

Request help in understanding what exactly is wrong here.

rupesh
  • 413
  • 9
  • 19

1 Answers1

0

Actually the issue was something else. @Value was working fine. The attribute in payload was not getting injected, hence the test cases were failing.

Actuall issue you can refer here

rupesh
  • 413
  • 9
  • 19