wuchong commented on a change in pull request #14944: URL: https://github.com/apache/flink/pull/14944#discussion_r578568850
########## File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala ########## @@ -546,13 +555,16 @@ class TableEnvironmentTest { |) """.stripMargin - val code = new Callable[TableResult] { - override def call(): TableResult = tableEnv.executeSql(statement1) + try { + tableEnv.executeSql(statement1) + } catch { + case e: TableException => + assertTrue(e.getMessage.contains("Could not execute LOAD MODULE: (moduleName: [Dummy], " + + "properties: [{dummy-version=1}]). Could not find a suitable table factory for " + + "'org.apache.flink.table.factories.ModuleFactory' in\nthe classpath.")) + case e => + fail("This should not happen, " + e.getMessage) Review comment: ```scala try { tableEnv.executeSql(statement1) fail("Expected an exception") } catch { case t: Throwable => assertThat(t, containsMessage("Could not execute LOAD MODULE: (moduleName: [Dummy], " + "properties: [{dummy-version=1}]). Could not find a suitable table factory for " + "'org.apache.flink.table.factories.ModuleFactory' in\nthe classpath.")) } ``` We should add `fail` before catch and we can use `org.apache.flink.core.testutils.FlinkMatchers#containsMessage` here for a better error message when mismatching. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org