微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在Axe DevTools中添加全局标签证明 用法示例

如何解决如何在Axe DevTools中添加全局标签证明 用法示例

我正在使用Axe DevTools,并且试图弄清楚如何用相同的构建信息标记多个扫描。现在,我的测试正在这样运行:


     AlertDialog(
                    // change the default padding to zero
                    contentPadding: EdgeInsets.zero,title: Center(child: Text("Picture")),content: Column(
                      mainAxisSize: MainAxisSize.min,children: <Widget>[
                         // wrap your container with a padding widget
                         Padding(
                         padding: const EdgeInsets.all(20.0),// give a preferred padding
                         child: Container(
                         width: width,//height: height,placeholder: kTransparentimage,image: image.url,),SizedBox(
                          height: 10,InkWell(
                          onTap: () {
                            Navigator.pop(context);
                          },child: Container(
                            alignment: Alignment.center,height: 50,width: width,color: primaryColor,child: Text(
                              'Okay',style: TextStyle(
                                  color: Colors.white,fontWeight: FontWeight.bold),],);

如何将class MyTestCase : XCTestCase { func mytest() { Attest.that(view: view) .isAccessible({ result in }) .andPushResult(withTags: [myBuild]) } } 标记全局添加到我运行的所有测试中?

解决方法

我将构建自己的利用Ax DevTools(Attest)API的类。然后让我的测试用例与我自己的类交互,而不是与Attest本身交互!

myBuild

用法示例

class AccessibilityTestUtils {
  static let buildTag:String = Bundle.main.object(
    forInfoDictionaryKey: "CFBundleShortVersionString"
  ) as! String

  init(build: String) {
    self.buildTag = build
  }
    
  static func runAccessibilityTestOn(aView : View) {
    Attest.that(view: aView).isAccessible({ result in })
      .andPushResult(withTags: [buildTag])   
  } 
}

注意:这种方法还通过保护Attest库,使您免于以后对Attest库的更改,因此,在非向后兼容更改的情况下,只需更改一行代码即可。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。