Skip to main content

Generating Source Code Templates on the Basis of Unit Tests

  • Conference paper
  • First Online:

Part of the book series: Advances in Intelligent Systems and Computing ((AISC,volume 522))

Abstract

This paper describes the solution for supporting Test-driven development (TDD) methodology with the help of code analysis and generation. By automation of the creation of stub implementation, it helps to accelerate the process of passing a red phase of Red/Green/Refactor (RDR) cycle. The tool described in the paper performs a semantic analysis of the test methods defined in a subjected Java class. It uses the information gathered during a process for further generation of unit stubs. The proposed solution describes the way in which the Abstract Syntax Tree (AST) is analyzed by the statements tree decomposition. The paper also presents possible ways of preventing and resolving unit types conflicts. The tool used for stub generation of units was defined in one of the test methods implemented in a Log4J Java framework. The results obtained are compared to a real class definition, and possible ways for further extensions of the solution are suggested.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

References

  1. Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques, and Tools, 2nd edn. Addison-Wesley, Boston (2007)

    Google Scholar 

  2. Beck, K.: Test-Driven Development by Example. The Addison-Wesley Signature Series, Addison-Wesley, Boston (2003)

    Google Scholar 

  3. Earlay, J.: An efficient context-free parsing algorithm. Commun. ACM 13(2), 94–102 (1970)

    Article  Google Scholar 

  4. Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A.: The Java Language Specification. Java SE 8 Edition. Oracle America, Inc. (2015), [http://docs.oracle.com/javase/specs/jls/se8/jls8.pdf]

  5. Grune, D., van Reeuwijk, K., Bal, H., Jacobs, C., Langendoen, K.: Modern Compiler Design. Springer, Berlin (2012)

    Google Scholar 

  6. Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, 3rd edn. Addison Wesley, Boston (2006)

    Google Scholar 

  7. Shore, J., Warden, S.: The Art of Agile Development. O’Reilly, Beijing (2007). [http://my.safaribooksonline.com/9780596527679]

  8. Sun Microsystems, Inc: JSR 199: Java Compiler API (2006). [https://jcp.org/en/jsr/detail?id=199]

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Mariusz Nyznar .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Nyznar, M., Pałka, D. (2017). Generating Source Code Templates on the Basis of Unit Tests. In: Grzech, A., Świątek, J., Wilimowska, Z., Borzemski, L. (eds) Information Systems Architecture and Technology: Proceedings of 37th International Conference on Information Systems Architecture and Technology – ISAT 2016 – Part II. Advances in Intelligent Systems and Computing, vol 522. Springer, Cham. https://doi.org/10.1007/978-3-319-46586-9_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-46586-9_17

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-46585-2

  • Online ISBN: 978-3-319-46586-9

  • eBook Packages: EngineeringEngineering (R0)

Publish with us

Policies and ethics