문제

I'm using Mocha Library and the Library by default use a Test folder. So, I have to copy the code I written in production into Test folder when doing Unit Tests with Mocha.

Anyone can think reason behind this method? Is it appropriate?

I'm just a hobbyist, haven't done programming for large companies. I also avoided unit tests thru Mocha for years but it seems it's right time for me to actually start to use Mocha to remove manual testing pain.

EDIT: Actually, I can import the code directly from Production but the practice among examples I witnessed is to use dedicated folder for Unit Tests, I looking to understand reasons behind this practice.

도움이 되었습니까?

해결책

It's normal to keep tests in a separate directory because they are not part of the code that would be deployed. But it's also standard practice to import the code you want to test into the test code, without copying any code around.

For illustration, I opened up a random test from Mocha.JS' own test suite, and it does this:

var Mocha = require('../../lib/mocha');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top