Jasmine:如何获得当前测试的名称 [英] Jasmine: How to get name of current test

查看:118
本文介绍了Jasmine:如何获得当前测试的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获取当前正在运行的测试的名称?

Is there a way of getting the name of the currently running test?

一些(大大简化的)代码可能有助于解释。我希望在对 performTest 的调用中避免重复test1/test2

Some (heavily simplified) code may help explain. I want to avoid the duplication of "test1" / "test2" in the calls to performTest:

describe("some bogus tests", function () {

    function performTest(uniqueName, speed) {
        var result = functionUnderTest(uniqueName, speed);
        expect(result).toBeTruthy();
    }

    it("test1", function () {
        performTest("test1", "fast");
    });

    it("test2", function () {
        performTest("test2", "slow");
    });
});






更新
我看到我需要的信息是:


UPDATE I see the information I need is in:

jasmine.currentEnv_.currentSpec.description

或者可能更好:

jasmine.getEnv().currentSpec.description


推荐答案

jasmine.getEnv().currentSpec.description

这篇关于Jasmine:如何获得当前测试的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆