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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques, and Tools, 2nd edn. Addison-Wesley, Boston (2007)
Beck, K.: Test-Driven Development by Example. The Addison-Wesley Signature Series, Addison-Wesley, Boston (2003)
Earlay, J.: An efficient context-free parsing algorithm. Commun. ACM 13(2), 94–102 (1970)
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]
Grune, D., van Reeuwijk, K., Bal, H., Jacobs, C., Langendoen, K.: Modern Compiler Design. Springer, Berlin (2012)
Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, 3rd edn. Addison Wesley, Boston (2006)
Shore, J., Warden, S.: The Art of Agile Development. O’Reilly, Beijing (2007). [http://my.safaribooksonline.com/9780596527679]
Sun Microsystems, Inc: JSR 199: Java Compiler API (2006). [https://jcp.org/en/jsr/detail?id=199]
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights 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)