XCTest 没有将新方法注册为测试 [英] XCTest not registering new methods as tests

查看:36
本文介绍了XCTest 没有将新方法注册为测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看似奇怪的问题(除非我遗漏了一些非常明显的东西!)并且很好奇这里是否有人有任何见解.我已经做了很多搜索,但没有找到任何东西.

I have a seemingly weird problem (unless I'm missing something totally obvious!) and am curious if anyone here has any insight. I've done quite a bit of searching and haven't found anything.

当我尝试在 XCTest 中编写单元测试 - 创建新方法 - 它们似乎没有注册为测试,并且在我运行测试套件时也不会执行.他们也没有旁边那些漂亮的小菱形运行按钮之一,可以让您运行单独的测试:

When I try and write unit tests in XCTest - creating new methods - they don't seem to register as tests and aren't executed when I run the test suite. They also don't get one of those nice little diamond run buttons next to them that allows you to run individual tests:

例如在这里使用 JUnit 时,您将使用 @Test 进行注释.我缺少这样的东西吗?

When using JUnit for example here you would annotate with @Test. Anything like this I'm missing?

推荐答案

只有以 test 开头的方法名称才被识别为测试.这样你仍然可以在你的测试类中使用你的实际测试方法可以调用的普通方法.

Only method names that start with test are being recognized as tests. That way you can still use normal methods in your test classes that your actual test methods can call.

这篇关于XCTest 没有将新方法注册为测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆