[KYUUBI #4912] [TEST] Replace Scala's assert in tests with Scalatest's for prettified error message

### _Why are the changes needed?_

- replacing callings to Scala's assert method by Scalatest's `Assertions.assert`
- While Scala's assert method just throws a simple Java's Assertion Error ,
```
  def assert(assertion: Boolean) {
    if (!assertion)
      throw new java.lang.AssertionError("assertion failed")
  }
```
the Scalatest's `Assertions.assert` prettifies the error message, eg.,
`assert(a == b || c >= d) // Error message: 1 did not equal 2, and 3 was not greater than or equal to 4`

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #4912 from bowenliang123/scalatest-assert.

Closes #4912

e1d2ce3e0 [liangbowen] use Scalatest's assert for better error message

Authored-by: liangbowen <liangbowen@gf.com.cn>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
liangbowen 2023-06-01 11:52:56 +08:00 committed by Cheng Pan
parent f979282179
commit bbf855df0e
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D
5 changed files with 5 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import java.io.{File, FileOutputStream, OutputStream}
import scala.collection.JavaConverters._
import com.google.common.reflect.ClassPath
import org.scalatest.Assertions._
trait KyuubiBenchmarkBase {
var output: Option[OutputStream] = None

View File

@ -23,7 +23,7 @@ import java.security.PrivilegedExceptionAction
import org.apache.hadoop.security.UserGroupInformation
import org.apache.spark.SparkConf
import org.apache.spark.sql.{DataFrame, Row, SparkSession, SparkSessionExtensions}
import org.scalatest.Assertions.convertToEqualizer
import org.scalatest.Assertions._
import org.apache.kyuubi.Utils
import org.apache.kyuubi.plugin.spark.authz.RangerTestUsers._

View File

@ -22,6 +22,7 @@ import java.io.{File, FileOutputStream, OutputStream}
import scala.collection.JavaConverters._
import com.google.common.reflect.ClassPath
import org.scalatest.Assertions._
trait KyuubiBenchmarkBase {
var output: Option[OutputStream] = None

View File

@ -21,7 +21,7 @@ import javax.security.sasl.AuthenticationException
import scala.collection.mutable
import org.scalatest.Assertions.{fail, intercept}
import org.scalatest.Assertions._
import org.apache.kyuubi.config.{ConfigEntry, KyuubiConf}
import org.apache.kyuubi.service.authentication.LdapAuthenticationProviderImpl

View File

@ -37,6 +37,7 @@ import org.apache.hadoop.security.{Credentials, UserGroupInformation}
import org.apache.hadoop.security.authorize.ProxyUsers
import org.apache.thrift.TProcessor
import org.apache.thrift.protocol.TProtocol
import org.scalatest.Assertions._
import org.scalatest.concurrent.Eventually._
import org.scalatest.time.SpanSugar.convertIntToGrainOfTime