我对 VR 完全陌生,正在 AFrame 中为一个班级项目开发 VR 太空射击游戏,想知道 AFrame 中是否有 TDD 的任何文档/标准。有人能指出我正确的方向吗?
几乎完全使用 A 框架组件构建您的应用程序:https://aframe.io/docs/0.4.0/guides/writing-a-component.html
然后测试组件。 A-Frame 代码库中的几乎每个组件都有单元测试: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.
});
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)