问题描述
我对VR完全陌生,正在AFrame中为一个班级项目开发Vr空间射击游戏,想知道AFrame中是否有TDD的任何文档/标准。有人能指出我正确的方向吗?
I'm totally new to VR and am working on a Vr space shooter in AFrame for a class project and was wondering if there is any documentation/standards for TDD in AFrame. Could anyone point me in the right direction?
推荐答案
几乎完全在A-Frame组件中构建应用程序:
Build your application almost entirely in A-Frame components: https://aframe.io/docs/0.4.0/guides/writing-a-component.html
然后测试组件。 A-Frame代码库中的几乎每个组件都有单元测试:
Then test the components. Just about every component in the A-Frame codebase has unit tests: https://github.com/aframevr/aframe/tree/master/tests/components
角的组件模板
还有一个单元测试设置。 (对于独立组件,)。
The component template in angle
also has a unit test setup. https://github.com/aframevr/angle/tree/master/templates/component (npm install -g angle && angle initcomponent
for a standalone component).
测试使用Karma启动真正的浏览器并执行代码。它将实体附加到DOM,并附加具有不同属性值的组件,然后声明值。一个基本示例:
The tests use Karma to spin up a real browser and execute code. It appends entities to the DOM, and attaches components with different property values, and asserts values. A basic example:
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.
});
});
});
这篇关于编写A-Frame的测试规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!