Jiabao-Sun commented on code in PR #23358:
URL: https://github.com/apache/flink/pull/23358#discussion_r1319983416
##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/expressions/utils/ExpressionTestBase.scala:
##########
@@ -138,33 +131,28 @@ abstract class ExpressionTestBase(isStreaming: Boolean =
true) {
invalidTableApiExprs.clear()
}
- @After
+ @AfterEach
def evaluateExprs(): Unit = {
// evaluate valid expressions
evaluateGivenExprs(validExprs)
// evaluate invalid expressions
invalidSqlExprs.foreach {
- case (sqlExpr, keywords, clazz) => {
- try {
+ case (sqlExpr, keywords, clazz) =>
+ val callable: ThrowingCallable = () => {
val invalidExprs = mutable.ArrayBuffer[(String, RexNode, String)]()
addSqlTestExpr(sqlExpr, keywords, invalidExprs, clazz)
evaluateGivenExprs(invalidExprs)
- fail(s"Expected a $clazz, but no exception is thrown.")
- } catch {
- case e if e.getClass == clazz =>
- if (keywords != null) {
- assertTrue(
- s"The actual exception message \n${e.getMessage}\n" +
- s"doesn't contain expected keyword \n$keywords\n",
- e.getMessage.contains(keywords))
- }
- case e: Throwable =>
- e.printStackTrace()
Review Comment:
The changed code will print similar fail messages as the old code.
I think we needn't keep the redundant fail messages. WDT?
```java
if (keywords != null) {
assertThatExceptionOfType(clazz)
.isThrownBy(callable)
.withMessageContaining(keywords)
} else {
assertThatExceptionOfType(clazz)
.isThrownBy(callable)
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]