简体   繁体   English

如何在Node.js源代码中运行测试?

[英]How can I run the tests in the Node.js source code?

I made some changes to the Node.js source code and wondered about whether these changes are valid. 我对Node.js源代码进行了一些更改,并想知道这些更改是否有效。 But I don't know how to run the tests written before in the "tests" folder. 但是我不知道如何运行之前在“ tests”文件夹中编写的测试。

I've been exploring the source code of Node.js recently in order to do some research. 为了进行一些研究,我最近一直在探索Node.js的源代码。 I use an early version of Node.js but I think it won't make much difference in testing. 我使用的是早期版本的Node.js,但我认为它在测试中不会有太大的不同。 I found there are test files written in javascript and c. 我发现有用javascript和c编写的测试文件。 Additionally there is a python file in each folder together with its js test files. 此外,每个文件夹中都有一个python文件及其js测试文件。 First I searched issues in GitHub repository for help about testing Node.js source code but failed. 首先,我在GitHub存储库中搜索问题,以寻求有关测试Node.js源代码的帮助,但失败了。 Then I asked Google but just got the answer about using Mocha or other tools to test programs running on Node.js. 然后我问Google,但是得到了有关使用Mocha或其他工具测试在Node.js上运行的程序的答案。 I also searched on stackoverflow but sadly found there is no answers for my question. 我也搜索了stackoverflow,但可悲的是我的问题没有答案。 A tests folder of Node.js has structure like this: Node.js的测试文件夹的结构如下:

tests folder structure 测试文件夹结构

I've tried to use python to run the python file in tests folder but failed. 我试图使用python在tests文件夹中运行python文件,但是失败了。 After reading the relevant code, I thought it should work but:< 阅读相关代码后,我认为它应该可以工作,但是:
Also I tried to use nodejs to run the javascript files. 我也尝试使用nodejs运行javascript文件。 Some of tests ran but some of them didn't output. 一些测试已经运行,但其中一些没有输出。 But running tests one by one is inefficient, I think there should be something wrong about my actions. 但是,一个接一个地运行测试效率低下,我认为我的行为应该有问题。

Kindly, let me share you a basic structure to run multiple tests automatically. 请允许我与您分享一个基本结构,以自动运行多个测试。

https://github.com/eum602/Basic-testing-Examples-Using-NodeJS https://github.com/eum602/Basic-testing-Examples-Using-NodeJS

Good Luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM