Skip to content

Create and Deploy a Virtual Service before Any Test from the Class

sachinmaske edited this page Oct 20, 2022 · 1 revision

This example describes creating a virtual service at the class level.

Below annotation defines rules to create virtual service before any test from class.

@ClassRule
public static VirtualServiceClassScopeRule clazzRule = new VirtualServiceClassScopeRule();

The scope of this annotation starts from the execution of the first step until the completion of the last step.

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = LisaBankClientApplication.class)
@DevTestVirtualServer()
@DevTestVirtualService(serviceName = "Proxy", type = VirtualServiceType.VSM, 
			workingFolder = "vsm/lisabank", parameters = {
		@Parameter(name = "port", value = "9081") })
public class ExistingVirtualServiceTest {

	// handle VS with Class scope
	@ClassRule
	public static VirtualServiceClassScopeRule clazzRule = new VirtualServiceClassScopeRule();
	@Rule
	public VirtualServicesRule rules = new VirtualServicesRule();

	static final Log logger = LogFactory.getLog(ExistingVirtualServiceTest.class);
	@Autowired
	private BankService bankServices;


	@Test
	public void getListUser() {

		try {
			User[] users = bankServices.getListUser();
			assertNotNull(users);
			printUsers(users);
			assertEquals(9, users.length);
		} finally {
			
		}

	}

	private void printUsers(User[] users) {
		for (User user : users) {
			logger.info(user.getFname() + " " + user.getLname() + " " + user.getLogin());
		}

	}
	
}

Getting Started

Code Library

Core Functionality

Version 1.4.0

Annotation DevTestVirtualServiceV3

Version 1.3.2

Acknowledgments

Clone this wiki locally