Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
216 views
in Technique[技术] by (71.8m points)

java 8 - Launch spring boot mvc test from custom testng framework

Where I'm working one of our customer required to use a custom test framework written using testng that allows to handle different parameters and test iterations using excel files.

This framework uses a main class to handle all the tests, lets call it TestManager.

This TestManager defines all the @Before and @After operations and has a method called exec() which is annotated as @Test.

This method is used to call the different components required from the test, these components are java classes that implements a single method exec() containing the logic of the single component.

    public class TestManager {
        // ... Before, After methods
    
        @Test(
                dataProvider = "..."
        )
        public void exec(Parameter[] inParameter) {
            // load parameters...
            foreach component:
                component.exec()
        }
    }
    public class ComponentXYZ {
        public void exec() {
        // load input params
        // Call a microservice and get results, find value on db, selenium operations...
        // unload output params for next components
        }
    }

This framework was designed to be used with selenium, or to test microservices using some http request library and is contained in a standalone module.

So my project has:

  • A spring boot module
  • A test module which (in my idea) should have a dependency over the spring boot module

Given this situation do you think it could be possible to use WebMvcTest to perform integration tests while using this custom framework?

I've been trying for a while but I'm always getting errors or I'm not able to @Autowire MockMvc, I can't seem to start a minimal spring boot instance directly from this test framework...

I don't think running my spring boot app and calling the microservices using http is the correct way to test but at this moment is the only thing it's working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...