2016-05-02 579 views
0

我已经开始为我的REST API编写测试用例。以下是代码。我没有获得个别测试用例的状态(通过/失败,测试用例名称等)。我知道有一些很琐碎,我很想念摩卡测试执行|个别测试用例无状态

代码:

**var supertest = require("supertest"); 
var should = require("should"); 
// This agent refers to PORT where program is runninng. 
var server = supertest.agent("http://localhost:1337"); 
// UNIT test begin 
describe("SAMPLE unit test",function(){ 
    // #1 should return home page 
    it("should return login details",function(done){ 
    // calling Login api 
    server 
    .post('/login') 
    .send({ loginid: "8787878787", password : "temp"}) 
    .expect("Content-type",/json/) 
    .expect(200) 
    .end(function(err,res){ 
     res.status.should.equal(200); 
     res.body.notFound.should.equal(false); 
     res.body.data.customerId.should.equal(20); 
     done(); 
    }); 
    }); 
    it("should return no active user",function(done){ 
    // calling home page api 
    server 
    .post('/login') 
    .send({ loginid: "8787878787", password : "temp1"}) 
    .expect("Content-type",/json/) 
    .end(function(err,res){ 
     res.body.notFound.should.equal(true); 
     done(); 
    }); 
    }); 
});** 

在命令提示符这是输出。它没有显示单独的测试用例状态(名称 - 在“它”块中所描述的内容,每个测试用例已经花费了多少时间等)

。 2合格(7s)

让我知道如何显示个别测试用例状态。

+0

谢谢!这已解决。 – Swapna

回答

1

摩卡在运行时有几个显示测试的选项。我认为,对于您的情况,您可能需要使用List。有更多选项here

因此,在终端,你会调用你的测试与 - mocha -R list tests/test.js

你也可以使用一个全局配置的摩卡从每次写报告类型有你,绝对,如果你有一个以上的测试文件。