在Rails应用中使用simple_cov
gem,我们是否可以在报告中包含我们未测试的文件?
如果是,怎么做?
如果不是,那些文件应该计入覆盖百分比,对吗?
答案 0 :(得分:51)
尝试修改config/environments/test.rb
并设置此行:
config.eager_load = false
到true
整个应用程序都被加载并且simplecov读取它。
答案 1 :(得分:14)
在运行带代码覆盖率的测试套件时,急切加载整个Rails应用。
将public void RegisterForPush(string token) {
Debug.Log("Parse updating instalation");
ParseInstallation instalation = ParseInstallation.CurrentInstallation;
instalation["deviceToken"] = token;
instalation["user"] = ParseUser.CurrentUser.ObjectId;
instalation["timeZoneOffset"] = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
instalation.SaveAsync();
}
添加到Rails.application.eager_load!
。
Simplecov减慢了测试的速度,这就是我使用shell环境变量打开它的原因。通常我的spec_helper.rb
/ spec_helper.rb
看起来像这样:
rails_helper.rb
答案 2 :(得分:1)
从0.11.0版开始,可以明确设置应跟踪的文件(Pull Request)。
对于以下的Rails应用程序:
class CommentParser():
def scrap(self, response):
print("from CommentParser.scrap =>", response.url)
for i in range(5):
yield scrapy.Request(url="https://www.somesite.com/comments/?page=%d" % i, callback=self.parse)
def parse(self,response):
print("from CommentParser.parse => ", response.url)
yield dict(response_url = response.url)
或简单易用:
if (listView.canScrollVertically(-1))
listView.smoothScrollToPosition(0);
else
onBackPressed();
默认情况下将设置要跟踪的文件(current related code)。