Allow setting raise_on_mismatches to base class level for tests
- 主要语言
- Ruby
- 星标
- 7.8k
- 派生
- 505
- PR 合并指标
- 30 天内没有已合并 PR
描述
We are using a base experiment class to manage our publish logic. All the actual experiments are extending from this base class. However, if we set raise_on_mismatches to this base class the result doesn't take effect as the method is using class instance variables(instead of class variables). In the end, people occasionally forget to use this test helper for their newly created experiments.
It would be great if we can manage this test helper via a base class. To elaborate more on this, this is somewhat our structure;
```ruby
class BaseExperiment
include Scientist::Experiment
def initialize
# setting up some instance variables mainly needed for publish logic
end
def publish(result)
# some custom logic
end
end
class WidgetExperiment < BaseExperiment
def initialize
# setting up custom variables
super
end
def enabled?
# custom enabled logic
end
end
class AnotherExperiment < BaseExperiment
# similar context with widget experiment
end
```
What we want is to use `BaseExperiment.raise_on_mismatches = true` to ensure all child experiments are tested on tests without needed a separate test setup. Would such a need make sense to you?
贡献指南
调研方向
首先跟踪 Scientist::Experiment 中 raise_on_mismatches 的实现,以及它如何在实验类上进行配置。为设置 BaseExperiment.raise_on_mismatches 添加测试覆盖,并验证子实验无需单独的测试设置即可遵循该设置。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ruby
- 领域
- backend
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100