简体   繁体   English

管理 testNG 中的大量环境特定测试数据

[英]Manage large amount of environment specific test data in testNG

I have an enterprise android application and a package created for testing the app.我有一个企业 android 应用程序和一个为测试应用程序而创建的 package。 The package runs on a framework that uses Appium and testNG. package 在使用 Appium 和 testNG 的框架上运行。 The test package has various tests that check the content, labels, functionality of the app.测试 package 有各种测试来检查应用程序的内容、标签和功能。 The package is able to run tests on the app in various stages like alpha, beta.. All the different stages have different test data. package 能够在 alpha、beta 等各个阶段在应用程序上运行测试。所有不同的阶段都有不同的测试数据。

For example, let's take a food delivery application.例如,让我们以一个送餐应用为例。 In this application, the testing is done through a test package that can run in various development stages (alpha, beta, gamma, prod).在此应用程序中,测试是通过测试 package 完成的,该测试可以在不同的开发阶段(alpha、beta、gamma、prod)运行。 There can be different types of orders like with long and short distances, discount and without discount, delivery orders and dine-in bookings etc. which will be different for different stages.可以有不同类型的订单,例如长距离和短距离,折扣和不折扣,送货订单和堂食预订等,不同阶段会有所不同。

I need a way of managing this test data in a generic way in JAVA .我需要一种在JAVA中以通用方式管理此测试数据的方法。 Like in JS, we can have TestData.BETA.DISCOUNT_ORDER.EMAIL_ID , TestData.PROD.DISCOUNT_ORDER.EMAIL_ID就像在 JS 中一样,我们可以有TestData.BETA.DISCOUNT_ORDER.EMAIL_IDTestData.PROD.DISCOUNT_ORDER.EMAIL_ID

I have tried java relflection but it becomes very complex when dealing with maps, innerclasses and maps inside innerclasses.我已经尝试过 java 反射,但是在处理映射、内部类和内部类内部的映射时它变得非常复杂。

I ended up creating classes like:我最终创建了如下类:

CommonTestData

which is inherited by这是由

AlphaTestData
BetaTestData
GammaTestData
ProdTestData

and an interface implemented by all of these that would return the correct object based on the current environment stage.以及由所有这些实现的接口,这些接口将根据当前环境阶段返回正确的 object。

TestDataController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM