【发布时间】:2014-12-08 08:18:25
【问题描述】:
我正在使用 mocha 框架实现 logger(winston) 的集成测试。
假设我使用logger.error。并使用它创建一个文件。
我必须检查文件是否已创建
但是我必须在检查它的存在后删除这个文件。
// on file is created and logged the data
logger.error("module.testnamespace.info", "Info message", 1231, 12313);
// Checking the existance of that file
fs.exists(filePath, function (exists) {
should(exists).equal(true, 'Log File should exist');
});
// I want to delete that file
fs.unlinkSync(filePath);
但在这里我得到了这个错误
1) 1. Integration Test Cases for logger wrapper : for `info` method A. Integration Test Cases for logger wrapper : for `info` method a. Check logger file is creating or not:
Error: ETXTBSY, text file is busy '/web/log/rpc-test.log.2014-12-08'
at Object.fs.unlinkSync (fs.js:760:18)
at Context.<anonymous> (/web/gin/mochaTest/rpcTest/logger_rpc_test.js:49:10)
at Test.Runnable.run (/web/gin/node_modules/mocha/lib/runnable.js:194:15)
at Runner.runTest (/web/gin/node_modules/mocha/lib/runner.js:372:10)
at /web/gin/node_modules/mocha/lib/runner.js:448:12
at next (/web/gin/node_modules/mocha/lib/runner.js:297:14)
at /web/gin/node_modules/mocha/lib/runner.js:307:7
at next (/web/gin/node_modules/mocha/lib/runner.js:245:23)
at Object._onImmediate (/web/gin/node_modules/mocha/lib/runner.js:274:5)
at processImmediate [as _immediateCallback] (timers.js:336:15)
【问题讨论】:
标签: node.js testing logging integration-testing mocha.js