• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Parsing strategy

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all!
I'm writing a parser to generate JUnit-like files from a custom test format used in one of our products. The product is not writted in Java, so we cannot rewrite the tests to JUnit, but our build statistics tool only reads JUnit-format.
What I'd like some help with is evaluating if I'm doing this in a smart way, or if you can suggest a better one. Below is my current idea.
The files generated by our test tool look like this (part of acual output):

So each line is date, time, log severity, test facility and status message.
The approach I'm currently using reads the input into an arraylist of hashmaps, and removes header/footer and other "uninteresting" lines.
Then I iterate over the ArrayList, and depending on what is in the status field, I do different things.
However, I'm finding this increasingly difficult. The test is started with a line with a status "Test: <TESTNAME>...", then any output during the test, and then "Test: <TESTNAME> [ <TEST OUTCOME> ] ( <FAILED/TOTAL> )".
So I'd have to save a temporary var with the current test name, collect any lines in another temporary var, until I find the test name again.
Is this really a good strategy?
Also, is the JUnit-XML format specified somewhere? I've googled but haven't found anything. Since there are multiple Script-sections, I thought I'd create a separate <testsuite>, and thus file, for each. However, there are sometimes nested Scripts, how would you handle this?

Best regards
Carl Pettersson
[ July 03, 2008: Message edited by: Carl Pettersson ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this were my problem I'd use a lexer such as JFlex, which makes it much easier to associate Java code to particular text inputs.
 
Carl Pettersson
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've had a look at it (read the manual), and it seems rather more complicated than I'd hoped. I'll try it though, but any ideas on my approach are still very welcome!
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic