td
10 years agoRegular Visitor
Hi,
We solved this issue by using the following Gradle/Groovy-based code, that updates the TC12 project to enable only the wanted test items to run:
def patchMdsFile(Project project, File mdsFile) {
def testItemToEnable = project.properties.testItem
if (!testItemToEnable)
throw new GradleException('Please set the `testItem` parameter (string containing the name of the test item to enable).')
project.logger.lifecycle("Enabling test item ${testItemToEnable} in ${mdsFile}...")
def mdsRoot = new XmlParser(false, false, true).parse(mdsFile)
def projectVersion = VersionNumber.parse(mdsRoot.@version.toString())
project.logger.info("Detected project version ${projectVersion}")
if (projectVersion < VersionNumber.parse('12.0.0'))
throw new GradleException("The project file uses an unsupported TestComplete version (${projectVersion}). Please upgrade your project to version 12 or above.")
mdsRoot.testItems.children.testItem.each {
def isEnabled = it.@name == testItemToEnable
project.logger.info("Test item '${it.@name}' enabled flag: ${isEnabled}")
it.@enabled = isEnabled
}
mdsFile.write(XmlUtil.serialize(mdsRoot))
}