Think of them as a necessary evil or a brain-sharpening gym for your coding skills. Love them or grudgingly accept their existence, if you're aiming to be a programmer, test tasks are usually inescapable. Yep, we're talking about test assignments here.
In this lecture, we're going to explore the different types of test tasks and how best to tackle them, including the often-overlooked aspects.
Types of Test Assignments
- Long-term tasks (from 3 days to a week or even two): These are marathon-like challenges.
- Short tasks (2-3 hours): Usually, you get a call, receive the task, and a few hours later, it's time to submit whatever you've managed to put together.
Stages of Completing a Test Task
To avoid getting lost, we recommend breaking down the solution into several stages. Let's check them out.
Preparation Stage (before the coding begins!)
Understanding the task: This is crucial. In real-world programming too, it's super important to make sure you've got the client's requirements down pat.
Ask questions if something's unclear: Sometimes, tasks are deliberately vague to prompt questions. Asking can often reveal a developer's level. Usually, you'll get answers, but sometimes you might be told to proceed as you deem fit, testing your responsibility and creativity.
Consider boundary cases: In the simplest terms - think of the largest and smallest possible data inputs. For example, if tasked with creating a URL shortener, consider an empty string or an exceptionally long one.
Think through all checks, outcomes, and what's within or outside the business scenario of the task: Understand what's expected as input and output. For the URL shortener example, a business scenario is receiving a link, while a non-business scenario is receiving a non-link. Since additional checks take extra time, discuss with the task issuer if they should be considered. This shows your understanding of the need for such checks.
Only after thorough planning and clarification, move to coding.
Coding Stage
Start with a rough draft: Don't aim for perfect, structured code right away - that's time-consuming. The main goal is functionality. Implement the bare minimum to solve the task, check your solution's correctness, address all checks and edge cases. Initially, a single large main class might suffice. Sometimes, you might find your solution doesn't fit, and if you've already planned out all classes and patterns for the wrong solution, it's just a waste of time.
Once the code works correctly and your hypothesis is confirmed, proceed with iterative refactoring: Gradually improve the code without breaking anything. If time allows, create smaller classes, apply necessary patterns, etc., until you achieve clean code and adhere to SOLID principles.
Cover your code with tests: If there's not enough time to refine the code completely, at least break it down into classes and cover it with tests. Tests are crucial as they often reveal problems effectively.
Presentation Stage
If your task is to create a web application, you might deploy it. However it's better to discuss this moment in advance and carefully review the conditions. Sometimes, deployment and GitHub usage are discouraged, and other times they're encouraged.
After solving the task, refactoring the code, and covering everything with tests, it's time to start formatting the test task: Write a Readme explaining your solution and describing the main classes. Sometimes, you may not have direct contact with the person reviewing your test task, and even a discussion may not occur. If your Readme is formatted in a way that makes it easy for the reviewer to check your work, the chances of a positive outcome increase.
What Should Be Included in a Test Task (Especially a Long One)?
Must-Haves:
- README (make everything easy to check),
- Use of Maven/Gradle (show you can handle these technologies),
- SOLID principles,
- Integration and unit tests,
- Clean code.
Nice-to-Haves:
- Logging,
- Upload the project to GitHub (unless instructed otherwise),
- Apply CI/CD,
- Docker/Docker-compose,
- DB migration,
- Swagger,
- Deployment.
Important! After submitting the task, always request feedback. Even if you're rejected, ask what was wrong with your code. This will help you understand whether the company's decision was objective or not.