How to run the Unit tests of the examples on the fly

Help requests on developing Logtalk applications

Moderator: Paulo Moura

Post Reply
pedrofmj
Posts: 20
Joined: Sun Jan 18, 2015 1:15 pm

How to run the Unit tests of the examples on the fly

Post by pedrofmj » Tue Jan 20, 2015 1:04 pm

Hi there Dr. Paulo,

I would like to run the unit tests from the examples (e.g. ack) outside the logtalk_tester tool, inside my application.

I want to do this because my application it's a Java application that uses Logtalk, and I'm adding unit tests for Logtalk there.

The unit tests are mandatory for the purpose of the application.

Thank you,

Pedro Ferreira.

pedrofmj
Posts: 20
Joined: Sun Jan 18, 2015 1:15 pm

Re: How to run the Unit tests of the examples on the fly

Post by pedrofmj » Tue Jan 20, 2015 1:15 pm

I could solve.

I just ran directly tester.lgt after loading logtalking into the application.

Thanks by the way!

pedrofmj
Posts: 20
Joined: Sun Jan 18, 2015 1:15 pm

Re: How to run the Unit tests of the examples on the fly

Post by pedrofmj » Tue Jan 20, 2015 2:53 pm

The output of the JUnit tests are ok, but I received a lot of redefinition warning messages:

Here is a part of them:

[exec] [junit] Warning: /home/pedrofmj/logtalk/examples/people/.lgt_tmp/tests_lgt.pl:2:
[exec] [junit] Redefined static procedure $tests#0._dcl/6
[exec] [junit] Previously defined at /home/pedrofmj/logtalk/examples/ack/.lgt_tmp/tests_lgt.pl:2
[exec] [junit] Warning: /home/pedrofmj/logtalk/examples/people/.lgt_tmp/tests_lgt.pl:3:
[exec] [junit] Redefined static procedure $tests#0._dcl/4
[exec] [junit] Previously defined at /home/pedrofmj/logtalk/examples/ack/.lgt_tmp/tests_lgt.pl:3

Are they important? I understand that it says that the new ones are overloading the old ones, what for me is ok. Maybe I can keep the warnings.

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: How to run the Unit tests of the examples on the fly

Post by Paulo Moura » Tue Jan 20, 2015 3:39 pm

You're loading multiple examples that define unit test objects with the same name. Hence the redefinition warning messages.
Paulo Moura
Logtalk developer

pedrofmj
Posts: 20
Joined: Sun Jan 18, 2015 1:15 pm

Re: How to run the Unit tests of the examples on the fly

Post by pedrofmj » Tue Jan 20, 2015 5:02 pm

Ok Dr. Paulo, understood.

Continuing with the subject Unit tests.

I'm running througth JPL over SWI Prolog/Java

When some test fails, it doesn't raise an error so that JUnit from Java can catch the error.

Is there an option for that? Or does it require modification?

Thanks,

Pedro.

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: How to run the Unit tests of the examples on the fly

Post by Paulo Moura » Tue Jan 20, 2015 7:15 pm

The test failure messages can be intercepted by defining the logtalk::message_hook/4 predicate. You can find the exact message term looking into the "tools/lgtunit/lgtunit_messages.lgt" file. For example:

Code: Select all

:- category(my_test_settings).

	:- multifile(logtalk::message_hook/4).
	:- dynamic(logtalk::message_hook/4).

	logtalk::message_hook(failed_test(Test, File, Position, Reason), _, lgtunit, _) :-
		% inform the Java side of the failed unit test
		...

:- end_category.
Paulo Moura
Logtalk developer

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest