简体   繁体   English

如果不包含根应用,则钢筋eunit会跳过所有应用测试

[英]Rebar eunit skips all app tests if root app is not included

my problem is that I can't run eunit tests for a single app or module without including the root app. 我的问题是,如果不包含根应用程序,则无法为单个应用程序或模块运行eunit测试。 My directory laylout looks a bit like this: 我的目录laylout看起来像这样:

├── apps
│   ├── app1
│   └── app2
├── deps
│   ├── amqp_client
│   ├── meck
│   ├── rabbit_common
│   └── ranch
├── rebar.config
├── rel
└── src
    ├── rootapp.app.src
    ├── rootapp.erl
    ├── rootapp.erl
    └── rootapp.erl

Now, what I can do is: 现在,我可以做的是:

$ rebar eunit skip_deps=true

which runs the tests for all apps. 它将运行所有应用程序的测试。 Also, I can do: 另外,我可以这样做:

$ cd apps/app1/
$ rebar eunit skip_deps=true

which runs the tests for app1 (I have a rebar.config in apps/app1 as well. 它运行app1的测试(我在apps / app1中也有一个rebar.config。

However, if I try 但是,如果我尝试

$ rebar eunit skip_deps=true apps=app1

does...nothing. 什么也没做。 no output. 没有输出。 Trying verbose mode gives me: 尝试详细模式会给我:

$ rebar -vv eunit skip_deps=true apps=app1
DEBUG: Consult config file "/Users/myuser/Development/erlang/rootapp/rebar.config"
DEBUG: Rebar location: "/usr/local/bin/rebar"
DEBUG: Consult config file "/Users/myuser/Development/erlang/erlactive/src/rootapp.app.src"
DEBUG: Skipping app: rootapp

When I include the root app, it works: 当我包含根应用程序时,它可以工作:

$ rebar eunit skip_deps=true apps=rootapp,app1

Despite the fact, that I actually want to test app1 , not rootapp , this is really uncomfortable since the SublimeErl plugin for SublimeText 2 will always set the apps to the app that the module under test is contained in. So the tests will always fail because actually no tests will run at all. 尽管事实上我实际上是要测试app1而不是rootapp ,但是这真的很不舒服,因为SublimeText 2的SublimeErl插件将始终将应用程序设置为包含被测模块的应用程序。因此,测试将始终失败,因为实际上,根本不会运行任何测试。

Long story short: Is there something I can configure in any of the rebar.config files to make it possible to run the tests for one app in /apps without including the root app? 长话短说:我可以在任何rebar.config文件中进行配置,以使在/apps运行一个应用程序的测试成为可能,而无需包括根应用程序吗?

Personally I prefer to put the main app into its own OTP compliant folder in apps . 我个人更喜欢把主要应用到自己的OTP兼容的文件夹apps Just create a new app rootapp in apps and include it in your rebar.config : 只需在apps创建一个新的应用程序rootapp并将其包含在rebar.config

{sub_dirs, ["apps/app1",
            "apps/app2",
            "apps/rootapp"]}.

You might also have to include the apps directory into your lib path: 您可能还必须将apps目录包含在您的lib路径中:

{lib_dirs, ["apps"]}.

You might want to have a look into Fred Herbert's blog post “As bad as anything else” . 您可能想看看Fred Herbert的博客文章“其他方面一样糟糕”

With this set up you should be able to run: 通过此设置,您应该能够运行:

rebar skip_deps=true eunit 

which will run all eunit tests of the apps in apps . 它将运行应用程序中apps所有eunit测试。

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

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