问题
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?
回答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
.
来源:https://stackoverflow.com/questions/7720919/how-to-use-eunittest-generate-a-xml-file-which-include-some-compling-info