emacstheviking
CommonTest help
Apologies for this but…
can anybody point me where to go to get some help with commontest under rebar3 …I have no hair left. I have read the official documentation until it now just looks like colored pixels on my monitor I can absorb no more. I’ve tried google groups, the trap_exit site looks dead ( years since I looked). I don’t know where to turn ![]()
I have never used ct before today… TBH either I am so dumb I don’t get it or it’s way too hard to get working, I’ve read the epgsql code again and again. I want a test suite to be able to drop and recreate a test database.
All I want is for my “application under test” to be able to “application:get_env/2” to work… it’s driving me freaking nuts. I had a bowel cancer op in March, I may well have to quite software engineering as this level of stress isn’t good for me I’m sure.
Thanks
Sean
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance











First 8 of 8 Posts
NobbZ
application:get_env/2should work, can you perhaps share a minimal project that shows your problem?PS: Remember that you need to make sure that the application is loaded before you can read its documentation. I’m not sure if CT did that by default.
emacstheviking
Hi Nobbz,
I don’t think I can really…I have a “dbms” module that calls application:get_env/2 and the results is always
undefinedexcept when running normally fromrebar shell.I have been driven to the edge of the maelstrom by commontest today to be honest.
Ironically even running under
rebar eunitis doing the same thing now…must have got out of bed the wrong way or something.running under
rebar3 shellhowever it’s fineand he is my
rebar.configfile for good measuremight as well throw in the failed suite as well
rvirding
What do you see when start common test, and how do you start it? Do you see the output from your calls to
ct:pall? Try adding an extra one to the start ofinit_per_suite/1function. What is shown in the generated HTML files?emacstheviking
I do see the print-and-log output in the HTML files, that’s not a problem. I just can’t figure out why I can’t load my application:get_env() without so much trouble!
It’s been a few years since I used Erlang and EUnit but I don’t remember having this trouble before, stuff just worked like it said it should.
I’ve probably done something fundamentally borked but these things never transpire to reveal themselves until one has walked at least three lengths of the Nakatome building in bare feet…
emacstheviking
Nobbz, I have realised that the application isn’t being loaded but I thought that at least running “rebar3 eunit” would do that for me but it doesn’t look that way.
I’ll be honest, I have found reading the manuals regarding EUnit and COmmonTest to be absolutely fruitless when trying to find a plain simple example of what I need: ensuring that my
src/scofblog.app.srcis to hand at runtime.That’s one thing I do remember, that the manuals are not the best sources of beginner level examples, I googled for about three hours on and off, found plenty of “solutions” but they are all years old and didn’t work anyway.
Still reading, gone back to EUnit manual and taking it one step at a time.

Again.
emacstheviking
Hello, sorry for the delay, went for a three hour walk to defuse my brain. Sore feet but clam head now.
I start with
rebar3 ctorrebar3 eunitand no extra command line options.Ultimately I lack the flying hours with the tools I guess. I have always loved Erlang since I first used it almost a decade ago and I do remember it being one tough cookie to crumble at times
rvirding
I have done most of my common test using the ct commands from the shell so I am not that into using rebar3. Can you check which applications are loaded and started.
rebar3 shelldoes it for you automatically but I don’t know how the testing works.emacstheviking
I woke early with my head full of stuff… anyway, I think I have solved my problem by the simple addition of
application:ensure_all_started, making my new workinginit_per_suitelike so:I found some code written by a work buddy from my current job, we use Erlang for talking to and from RabbitMQ and also to provide a common library that the Elixir applications use to “get on the bus”…lucky for me there was a -single- SUITE test that had that line in it, kind of obvious once you see it but not yesterday!
So, Robert, thanks for the nudges… a tad gutted I didn’t solve it myself but hell, at least I am moving forwards again, thanks again to everybody that helped a sometimes overly woud-up aging hacker…
I am still looking for a “solid” and “reliable” way to drop/recreate a test database, currently I create it manually and just truncate the tables to save some time…
Sean Charles.