0

I have some erlang file(.erl).And I compile them. Now I want to use some function to generate a xml which is about the compling info of these files.

Here is a address, http://www.erlang.org/doc/apps/eunit/eunit.pdf

In this pdf,There is a function eunit:test/2 which can generate a xml file.

eunit:test([fib, eunit_examples], [{report,{eunit_surefire,[{dir,"."}]}}]).

But i don't know these parameters represent. I just know fib = modulename dir = generate location.What about eunit_examples? ,report? ,eunit_surefire?

yiwei
  • 1

1 Answers1

1

I'm not really sure this is the function you are looking for. Eunit is a testing framework, and thus the function

eunit:test(...).

will give you information about any testing functions you have written within the modules.


If indeed you are looking to generate reports on those tests, in XML format, you simply use the form:

eunit:test([MODULES], [{report, {eunit_surefire, [{dir, "."}]}}]).

where MODULES is a list of any modules you want to do testing of, and everything else stays the same (for example, fib and eunit_examples are the two modules that are being tested in the example you gave.)

The report atom says that you want to generate a report, and the eunit_surefire atom says what format to generate the report with. I'm not sure there are any other ways to generate the reports with XML besides using eunit_surefire.

Xymostech
  • 9,710
  • 3
  • 34
  • 44
  • Oh thank you! It's very useful to me.I tried, it really works.And it generated a xml file. But I just got other questions. 1.Are there some other atoms can instead of "report",and generate a xml file which include other useful info? 2. If I want to generate other format, are there some other words I can use. – yiwei Oct 11 '11 at 08:01
  • It doesn't look like there are any other atoms that can be used to generate other data. `report` is all you've got, and it doesn't look like there are any other formats you can use, either. Sorry! – Xymostech Oct 11 '11 at 18:03
  • [This answer](http://stackoverflow.com/a/11340812/113848) has an example of an alternative report module implementation. – legoscia Jul 18 '12 at 15:30