Results 1 to 3 of 3
  1. #1
    ashu_i20 is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default Junit Automation with JAVA Parser


    I have a requirement to create a plugin which generate Junit test for any java class file. no

    To do that i want to know internals of a method as well.

    As far as in know reflection wont work here. I can not retrieve information about method calling or expr with that.

    Now i want to know if there is any JAVA parser which give me control when any method call or expr being executed in method body.

    I am evaluating Javaparser from google, but it looks like i have to make another pass to access details in filled object.
    If possible i want to create testcases in one pass only.

    I have used LEX and YACC for similar requirement once and it notified me whenever there is a syntax rule hit.
    I had written syntax rules and tokenizer for that. But i dont want to do same practice as writing JAVA parse rules will be pretty time taking and extensive.

    Please let me know what are the best parsing tools available for JAVA code parsing.


  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Junit Automation with JAVA Parser

    You do realise that those unit tests will be mostly useless?
    A Unit test should test how the code works against the requirements/spec.
    Not check how the code works against itself.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    ashu_i20 is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default Re: Junit Automation with JAVA Parser

    Tolls, I do agree with you that Generating test code from code is bizzare. Looks like misrepresentation of requirement.
    It will help creating a skelaton/mocking of external dependecy. And once we have mock ready, we can provide a plugin to configure data set. We can always insert the object which should play a role in unit testing derived from requirement/spec.

    Its matter of identifying the repitieve unit testing jobs and automating them. Minimizing the efforts from user perspective. We just want to provide some input.
    It could be just start we certainly can enhance it. Let me know if you agree.

Similar Threads

  1. Replies: 2
    Last Post: 03-22-2012, 12:54 PM
  2. Replies: 0
    Last Post: 05-13-2011, 08:38 PM
  3. how to use junit for a java class in netbeans
    By venkatakrishna.chaithanya in forum New To Java
    Replies: 0
    Last Post: 07-15-2009, 07:41 AM
  4. building automation software java issue
    By BASman in forum Advanced Java
    Replies: 6
    Last Post: 03-15-2009, 09:52 PM
  5. Help- UI Automation using Java
    By amitshrivastva in forum Advanced Java
    Replies: 3
    Last Post: 11-05-2008, 03:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts