Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnitXmlReporter #54

Closed
jitendrasbhati opened this issue Mar 19, 2014 · 12 comments
Closed

JUnitXmlReporter #54

jitendrasbhati opened this issue Mar 19, 2014 · 12 comments

Comments

@jitendrasbhati
Copy link

JUnitXmlReporter is not generating any output file after the test run.
The test runs successfully.
And i am running my testcases from eclipse
but while debugging i realized that it is not able to interpret the java code to write data to the file.How do i resolve this issue
?

@larrymyers
Copy link
Owner

Can you successful run your testcases via the command line and get a xml file with the results?

Running from within Eclipse isn't a use case that has been tested.

@jitendrasbhati
Copy link
Author

I havnt tried running those test cases from commandline

@jitendrasbhati
Copy link
Author

but yes they run successfully from eclipse.But i dont find any xml file being created.

@mgol
Copy link
Contributor

mgol commented Mar 25, 2014

I use Protractor with configuration from: https://github.com/angular/protractor/blob/master/spec/junitOutputConf.js

It used to generate the file but it doesn't currently. I'm on newest Protractor & jasmine-reporters.

@mgol
Copy link
Contributor

mgol commented Mar 25, 2014

It works for me in jasmine-reporters 0.2.1, doesn't work in any newer version.

@putermancer
Copy link
Collaborator

I just confirmed that. If you take a look at the history of jasmine.junit_reporters.js, though, you'll see that nothing has changed with the file writing logic since 51a3220 on April 13, 2013. I suspect there may be a change in protractor or jasmine-node which has changed the way file writing works.

The problem seems to be that you don't have a directory named xmloutput, and the JUnit reporter doesn't try to create directories (never has), it just tries to write new files at specific paths.

If you create an xmloutput directory, you should start getting output again.

@mgol
Copy link
Contributor

mgol commented Mar 25, 2014

@bloveridge Why does it work with jasmine-reporters until 0.2.1 then?

Also, my onPrepare function is as follows:

function onPrepare() {
    // The require statement must be down here, since jasmine-reporters
    // needs jasmine to be in the global and protractor does not guarantee
    // this until inside the onPrepare function.
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
        new jasmine.JUnitXmlReporter('test-results.protractor-chrome.xml', true, true));

    _onPrepare.apply(this, arguments);
}

which means no directiories are supposed to be created, only the single file.

@putermancer
Copy link
Collaborator

Man, 0.2.1 was released ages ago... two years? Really?

I'll spend some more time looking for what changed since 0.2.1, but you can still work around the issue by creating an xmloutput directory.

@mgol
Copy link
Contributor

mgol commented Mar 25, 2014

OK, then something must have changed in other projects as well since it was working for me a few months ago.

I don't understand why I should create an xmloutput directory when I don't want any directory to be created, I want the file in the root directory (and it used to work that way).

EDIT: months ago, not years, oops.

EDIT 2: actually, a few months ago 0.2.1 was the newest version so the cause seems to still exist in this project.

EDIT 3: OK, the change seems to be that older versions were just creating a file if I provided a name ending with *.xml whereas now they expect it always to be a directory.

@putermancer
Copy link
Collaborator

In that case, pass null for the path. I think I've discovered what is actually happening. (And no, creating an xmloutput directory wouldn't work for you, I posted that before I saw the changes you'd made to the example config you pushed.)

Previous versions of jasmine-reporters used savePath differently, and would assume it could be a fully qualified path, including filename. There were issues with the way it was done (see #19) and it was changed.

Now it is treated as a path not including filename. It looks for a directory with that name and tries to write files into that directory with names generated by reading your spec file. If you don't have the directory, it doesn't write the files.

If you use a path of null it will write to the current directory, again using the filenames generated by running the specs. You can now control the prefix (used to always be TEST-something.xml, now you can either remove it entirely or change the prefix to something else), but there isn't an option to completely override the filename. If you want that support, please consider adding it creating a pull request.

Here's the protractor config I use which appropriately writes files to the current directory:

            new jasmine.JUnitXmlReporter(null, true, true, 'testresults.e2e.'));

The resulting filenames are something like testresults.e2e.home.xml instead of TEST-home.xml

@mgol
Copy link
Contributor

mgol commented Mar 25, 2014

@bloveridge Great, thanks!

@putermancer
Copy link
Collaborator

@jitendrasbhati Please check your configuration for similar issues and let me know if it solves your problem.

Sorry all for this apparently-breaking change (at least in some cases like yours).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants