Class TestException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AssertionException, BenchmarkException, DataGenerationException, MockException

public class TestException extends OpenException
Test Exception - Base exception for test operations 测试异常 - 测试操作的基础异常

Base exception for all test-related errors, extending OpenException with test-specific error codes.

所有测试相关错误的基础异常,继承 OpenException 并提供测试专用错误码。

Features | 主要功能:

  • Extends OpenException for unified error handling - 继承 OpenException 统一异常处理
  • Test error code support - 测试错误码支持
  • Formatted message: [Test] (TEST-xxxx) message - 格式化消息

Usage Examples | 使用示例:

throw new TestException(TestErrorCode.ASSERTION_FAILED, "Values differ");

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
Since:
JDK 25, opencode-base-test V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • TestException

      public TestException(TestErrorCode errorCode)
      Create test exception with error code 使用错误码创建测试异常
      Parameters:
      errorCode - the error code | 错误码
    • TestException

      public TestException(TestErrorCode errorCode, String detail)
      Create test exception with error code and detail 使用错误码和详情创建测试异常
      Parameters:
      errorCode - the error code | 错误码
      detail - the detail message | 详细消息
    • TestException

      public TestException(TestErrorCode errorCode, Throwable cause)
      Create test exception with error code and cause 使用错误码和原因创建测试异常
      Parameters:
      errorCode - the error code | 错误码
      cause - the cause | 原因
    • TestException

      public TestException(String message)
      Create test exception with message 使用消息创建测试异常
      Parameters:
      message - the message | 消息
    • TestException

      public TestException(String message, Throwable cause)
      Create test exception with message and cause 使用消息和原因创建测试异常
      Parameters:
      message - the message | 消息
      cause - the cause | 原因
  • Method Details

    • getTestErrorCode

      public TestErrorCode getTestErrorCode()
      Get the typed test error code 获取类型化的测试错误码
      Returns:
      the test error code | 测试错误码