我对VR完全陌生,正在为一个类项目在AFrame中开发一个Vr空间射手,我想知道在AFrame中是否有任何关于测试驱动开发的文档/标准。有谁能给我指个方向吗?
发布于 2017-01-29 11:09:30
几乎完全在A框架组件中构建应用程序:https://aframe.io/docs/0.4.0/guides/writing-a-component.html
然后测试组件。几乎A框架代码库中的每个组件都有单元测试:https://github.com/aframevr/aframe/tree/master/tests/components
angle中的组件模板也有一个单元测试设置。https://github.com/aframevr/angle/tree/master/templates/component (独立组件的npm install -g angle && angle initcomponent)。
测试使用Karma启动真正的浏览器并执行代码。它将实体附加到DOM,并附加具有不同属性值的组件,并断言这些值。一个基本的例子:
suite('foo component', function () {
var component;
var el;
setup(function (done) {
el = entityFactory();
el.addEventListener('componentinitialized', function (evt) {
if (evt.detail.name !== 'foo') { return; }
component = el.components.foo;
done();
});
el.setAttribute('foo', {});
});
suite('update', function () {
test('bar', function () {
el.setAttribute('foo', 'bar', 10);
assert.equal(component.baz, 10); // Assert something.
});
});
});https://stackoverflow.com/questions/41916358
复制相似问题