Java Programming
Test Driven Development¶
Test-driven development (TDD) is a software development approach where tests are written before the actual code. The process typically follows these steps:
- Write a Test: You begin by writing a test that defines a small unit of functionality you want to implement.
- Run the Test: Execute the test. Since you haven't implemented the functionality yet, the test should fail.
- Write the Code: Implement the functionality to make the test pass.
- Run the Test Again: Execute the test suite again. If the new functionality passes the test, you're good to go. If not, you iterate on the code until it does.
- Refactor (if necessary): Once the test passes, you can refactor your code to improve its structure, readability, or performance, ensuring the tests still pass afterward.
This cycle continues throughout the development process, with developers continually adding new tests for new functionality and refactoring existing code.
- Why not wait until the code is written, and then whip out the test code?
-> A: The act of thinking through (and writing) the test code helps clarify your thoughts about what the method itself needs to do.
Annotations¶
- @Component -> Declare a class to be included as a component in the Spring Container
- @Component("lap1")
- @Autowired -> Try to search the dependent object automatically in the spring container for instantiation or initializatio
- @Qualifier("name") -> Searches by name in spring container instead of searching by type like @Autowired
- @RequestMapping("webpagename") - used to run specific code on specific web page