简体   繁体   中英

Unit test then build project? Or? What order for Java

I have to make some Java classes within a package using Netbeans. I have a question about the order I am supposed to do the following tasks: We are supposed to create unit tests, Javadoc things, and build the project (to make a JAR file that contains our class library). We will need to clean and build the project when we make changes. Can I start unit testing and documenting my code now before I have explicitly built the project? Or do I need to run the build first to pull things all together and then start unit testing and document with JavaDoc? Thank you for any help! Googling and searching here was getting me no where.

You'll need to have compiled the code before you can run tests on it.

Generally, a build system is responsible for managing all the steps, from assembling dependencies, through compiling, testing, and packaging. Different tools are optimized for different parts of the flow, though.

If you're starting up a Java project, I would recommend Apache Maven as a good all-in-one build system. Many other options and configurations exist, though.

There is no one answer for this question.
The more traditional way is code first and than tests, however, there is a design approach called TDD - test driven development . in this approach you actually start from the tests, and add the code according to failed tests.

You can read more about it here

Essentially, there's no right or wrong here, it depends on what you find more convenient

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM