How to use testIgnored method of io.kotest.engine.teamcity.TeamCityMessageBuilder class

Best Kotest code snippet using io.kotest.engine.teamcity.TeamCityMessageBuilder.testIgnored

TeamCityTestEngineListener.kt

Source:TeamCityTestEngineListener.kt Github

copy

Full Screen

...105 TestType.Test -> startTest(testCase)106 TestType.Dynamic -> Unit107 }108 }109 override suspend fun testIgnored(testCase: TestCase, reason: String?) {110 ignoreTest(testCase, TestResult.Ignored(reason))111 }112 private fun addChild(testCase: TestCase) {113 children.getOrPut(testCase.descriptor.parent) { mutableListOf() }.add(testCase)114 }115 override suspend fun testFinished(testCase: TestCase, result: TestResult) {116 results[testCase.descriptor] = result117 when (testCase.type) {118 TestType.Container -> {119 failTestSuiteIfError(testCase, result)120 finishTestSuite(testCase, result)121 }122 TestType.Test -> {123 if (!started.contains(testCase.descriptor)) startTest(testCase)124 if (result.isErrorOrFailure) failTest(testCase, result)125 finishTest(testCase, result)126 }127 TestType.Dynamic -> {128 if (isParent(testCase)) {129 startTestSuite(testCase)130 failTestSuiteIfError(testCase, result)131 finishTestSuite(testCase, result)132 } else {133 startTest(testCase)134 if (result.isErrorOrFailure) failTest(testCase, result)135 finishTest(testCase, result)136 }137 }138 }139 }140 private fun failTestSuiteIfError(testCase: TestCase, result: TestResult) {141 // test suites cannot be in a failed state, so we must insert a placeholder to hold any error142 when (val t = result.errorOrNull) {143 null -> Unit144 is MultipleExceptions -> t.causes.forEach { insertPlaceholder(it, testCase.descriptor) }145 else -> insertPlaceholder(t, testCase.descriptor)146 }147 }148 // returns true if this test case is a parent149 private fun isParent(testCase: TestCase) = children.getOrElse(testCase.descriptor) { mutableListOf() }.isNotEmpty()150 /**151 * For a given [TestCase] will output the "test ignored" message.152 */153 private fun ignoreTest(testCase: TestCase, result: TestResult.Ignored) {154 val msg = TeamCityMessageBuilder155 .testIgnored(prefix, formatter.format(testCase))156 .id(testCase.descriptor.path().value)157 .parent(testCase.descriptor.parent.path().value)158 .locationHint(Locations.location(testCase.source))159 .message(result.reason)160 .result(result)161 .build()162 println(msg)163 }164 /**165 * For a [TestCase] will output the "test started" message.166 */167 private fun startTest(testCase: TestCase) {168 val msg = TeamCityMessageBuilder169 .testStarted(prefix, formatter.format(testCase))...

Full Screen

Full Screen

TeamCityMessageBuilder.kt

Source:TeamCityMessageBuilder.kt Github

copy

Full Screen

...60 // note it seems that not attaching a message renders test failed irrelevant61 fun testFailed(prefix: String, name: String): TeamCityMessageBuilder {62 return TeamCityMessageBuilder(prefix, Messages.TEST_FAILED).addAttribute(Attributes.NAME, name)63 }64 fun testIgnored(name: String): TeamCityMessageBuilder = testIgnored(TeamCityPrefix, name)65 fun testIgnored(prefix: String, name: String): TeamCityMessageBuilder {66 return TeamCityMessageBuilder(prefix, Messages.TEST_IGNORED).addAttribute(Attributes.NAME, name)67 }68 }69 object Attributes {70 const val ACTUAL = "actual"71 const val EXPECTED = "expected"72 const val LOCATION_HINT = "locationHint"73 const val NAME = "name"74 const val DURATION = "duration"75 const val TIMESTAMP = "timestamp"76 const val TYPE = "type"77 const val DETAILS = "details"78 const val MESSAGE = "message"79 const val PARENT_ID = "parent_id"80 const val ID = "id"81 const val RESULT_STATUS = "result_status"82 }83 object Messages {84 const val TEST_SUITE_STARTED = "testSuiteStarted"85 const val TEST_SUITE_FINISHED = "testSuiteFinished"86 const val TEST_STARTED = "testStarted"87 const val TEST_FINISHED = "testFinished"88 const val TEST_IGNORED = "testIgnored"89 const val TEST_STD_OUT = "testStdOut"90 const val TEST_STD_ERR = "testStdErr"91 const val TEST_FAILED = "testFailed"92 }93 private val myText = StringBuilder(prefix).append("[$messageName")94 fun addAttribute(name: String, value: String): TeamCityMessageBuilder {95 myText96 .append(' ')97 .append(name).append("='")98 .append(Escaper.escapeForTeamCity(value))99 .append("'")100 return this101 }102 fun message(value: String?): TeamCityMessageBuilder =...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful