- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开始一个新项目并希望使用测试驱动开发。这是我的实体:
import 'package:aqueduct/aqueduct.dart';
class MyEntity extends ManagedObject<_MyEntity> implements _MyEntity {}class _MyEntity {
@primaryKey
int id;
int myValue;
}
void main() {
test('DatabaseBuilder returns multiple entities', () {
List<MyEntity> entities = [];
entities.add(MyEntity());
expect(entities.length, greaterThan(0));
});
}
Bad state: No entity found for '_MyEntity. Did you forget to create a 'ManagedContext'?
最佳答案
This question已在 Aqueduct Slack channel 上得到答复所以我把它移到这里更容易搜索。
Reductions answered :
You will need to start a
TestHarness
withTestHarnessORMMixin
mixed in. After that you can used the MnagedObject (sic) however you find fit.
Yes, what Reductions said… the framework handles TDD with the ORM by creating a temporary schema in your database server during testing (with the TestHarnessORMixin)
class Harness extends TestHarness<MyChannel> with TestHarnessORMMixin {
@override
Future onSetUp() async {
await resetData();
}
@override
Future onTearDown() async {}
@override
ManagedContext get context => channel.context;
}
Future main() async {
final harness = Harness()..install();
test('DatabaseBuilder returns multiple entities', () {
List<MyEntity> entities = [];
entities.add(MyEntity());
expect(entities.length, greaterThan(0));
});
}
class MyEntityModel implements _MyEntity {
@override
int id;
@override
int myValue;
}
关于database - Aqueduct :状态不佳:未找到 '_MyEntity' 的实体。您是否忘记创建一个 'ManagedContext' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59779847/
我正在开始一个新项目并希望使用测试驱动开发。这是我的实体: import 'package:aqueduct/aqueduct.dart'; class MyEntity extends Manage
我是一名优秀的程序员,十分优秀!