ArchUnitbasetypethrownwrong”
创始人
2024-09-12 07:30:33
0

这个问题一般发生在使用 ArchUnit 进行单元测试时,当期望的 BaseType 和实际传递的 Type 不匹配时会出现。可能的解决方法是明确期望的 BaseType 类型并进行检查,同时检查实际传递的 Type 是否符合预期。下面是一个示例代码:

ArchCondition myCustomCondition = new ArchCondition("my custom condition") {
  @Override
  public void check(T item, ConditionEvents events) {
    // Custom implementation
  }
}.as("my custom condition");

ArchRule rule = classes().that().areAnnotatedWith(MyAnnotation.class)
  .should().have(myCustomCondition);

JavaClasses classes = new ClassFileImporter().importPackages("my.example.package");
rule.check(classes);

在这个示例中,如果 T 类型不与 BaseType 匹配,则可能会抛出'ArchUnit base type thrown wrong”异常。为了解决这个问题,可以使用以下代码将 T 明确为预期的 BaseType 类型:

ArchCondition myCustomCondition = new ArchCondition("my custom condition") {
  @Override
  public void check(MyClassType item, ConditionEvents events) {
    // Custom implementation
  }
}.as("my custom condition");

ArchRule rule = classes().that().areAnnotatedWith(MyAnnotation.class)
  .should().have(myCustomCondition);

JavaClasses classes = new ClassFileImporter().importPackages("my.example.package");
rule.check(classes);

在这个代码示例中,显式指定了 MyBaseType 类型为 MyClassType,从而避免了'ArchUnit base type thrown wrong”异常。

相关内容

热门资讯

开挂辅助工具"aap... 较多好评“微乐万能挂官网”开挂(透视)辅助教程 了解更多开挂安装加(136704302)微信号是一款...
科技分享“微扑克作假吗”开挂辅... >>>您好:,软件加微信【添加136704302】确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...
开挂辅助工具"智星德... 开挂辅助工具"智星德州可以透视吗"开挂(透视)辅助安装(详细教程) 了解更多开挂安装加(136704...
必备教程“wepokerplu... 您好:wepokerplus辅助透视教程这款游戏是可以开挂的,软件加【添加微信客服136704302...
开挂辅助平台"wep... wepoker公共底牌 无需打开直接搜索微信:136704302本司针对手游进行,选择我们的四大理由...
研究成果“wepoker好牌率... 无需打开直接搜索加微信客服(136704302)咨询了解wepoker好牌率辅助器目前(微信:136...
开挂辅助安装"wep... 大家好,今天小编来为大家解答wepoker辅助插件功能这个问题咨询软件客服可以免费测试直接加微信(1...
推荐几款新版“WePoKer有... >>>您好:,软件加微信【添加136704302】确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...
开挂辅助下载"hhp... 开挂辅助下载"hhpoker脚本下载"开挂(透视)辅助下载(真实有挂)《详细加薇136704302咨...
必备辅助推荐“wepoker透... 您好:wepoker透视底牌脚本这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很...