lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi George,

> It seems that I cannot require my own package and use my methods from it...
> what I am doing wrong any clues?? I tried reading the examples but there is
> nothing which requires an external module? Looked also on luaforge at the
> other unit testing lib luaunit and it also has very basic examples.

You didn't show what's inside your "log" module, so it's difficult to
say, but if you are not using "module" call (and you shouldn't), then
you probably need to assign the result of your require "log" call:

local log = require "log"

Paul.

ZeroBrane Studio - slick Lua IDE and debugger for Windows, OSX, and
Linux - http://studio.zerobrane.com/

On Fri, Sep 28, 2012 at 12:50 PM, g.lister <g.lister@nodeunit.com> wrote:
> Hi guys,
>
> I have another newbie question this time on unit testing.
>
> I am trying to use lunit and I am having a problem with this code:
>
> require "lunit"
> require "log"
> print("Starting testing of log lib ...");
>
> module( "log_tests", lunit.testcase )
>
> function test_loglib()
>   assert_true(log ~= nil, "Log object must be defined!")
>   assert_true(type(log.debug) == "function", "log.debug method must exist!")
> end
>
> it blows up:
>
> gs@flipper:~/Lua/mystuff/db/files$ lunit ../../tests/log_tests.lua
> Starting testing of log lib ...
> Loaded testsuite with 1 tests in 1 testcases.
>
>     F
>
> 1 Assertions checked.
>
>   1) Failure (log_tests.test_loglib):
> ../../tests/log_tests.lua:8: true expected but was false
> ../../tests/log_tests.lua:8: Log object must be defined!
>
> It seems that I cannot require my own package and use my methods from it...
> what I am doing wrong any clues?? I tried reading the examples but there is
> nothing which requires an external module? Looked also on luaforge at the
> other unit testing lib luaunit and it also has very basic examples.
>
> TIA
> /george
>
>