简体   繁体   English

如何在elixir中为escript项目编写ExUnit测试用例

[英]How to write ExUnit test cases in elixir for an escript project

I have an escript project done in Elixir using mix. 我在Elixir中使用mix完成了一个escript项目。 The project has two or three .ex files that needs to be executed using certain arguments using the "escript" command It is like a client server based project where one escript run, starts the server(that keeps running) and a another escript run (in another terminal) connects to the server and does operations. 该项目有两个或三个.ex文件,需要使用“ escript”命令使用某些参数来执行。这就像一个基于客户端服务器的项目,其中一个escript运行,启动服务器(保持运行),另一个escript运行(在另一个终端)连接到服务器并执行操作。

How to write a test script using ExUnit (and run using mix run test) and call the client functions in the test file after starting server.? 启动服务器后,如何使用ExUnit编写测试脚本(并使用混合运行测试运行)并在测试文件中调用客户端函数?

I think the way I would recommend is to have the actual escript be a very thin wrapper around some Elixir module. 我认为我建议的方法是使实际的escript成为某些Elixir模块的非常薄的包装。 That way you can just test the module itself and the amount of code that is untested will be very small. 这样,您可以仅测试模块本身,而未经测试的代码量将非常小。

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

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