Let's use a ChatGPT shortcut for this explantion step:
Google's Foobar challenge is an invitation-only coding challenge that Google uses to identify and recruit talented programmers (being honest, they probably could offer a sort of internship if you're talent enough; not bad at all, anyway 💪)
It typically appears as a pop-up message on a user's screen when they are searching for coding-related terms on Google (like a creepy surprise; I thought I was being hacked)
Some people have reported receiving an invitation after searching for specific coding-related terms on Google; or have received an invitation through a referral (or looking for how to remove stain from carpet; whichever occurs first)
JUnit 5 is a popular open-source testing framework for Java applications. JUnit 5 provides several enhancements and new features making it more powerful and flexible for writing and executing tests.
Brief description of key features used in the current repo:
- Assertions API: offering a wide range of assertion methods for validating results.
- Parameterized Tests: allowing to write repeated testing with different sets of test data.
- Conditional Test Execution: concept of conditional test execution based on custom or predefined conditions.
- Test Instance Lifecycle: giving more control over resource management and test isolation.
- Test Execution Order: letting to define custom test execution orders by needs.
- Nested Tests: permitting to group related tests within a same test class, structuring methods in a hierarchical manner.
- Tagging and Filtering: enabling the capability of selectively execution based on categorizing.
- Where possible, It has been done with plain readable java; no streams used (clean code, I mean).
- Each task constructor was renamed using suffixes (ex: solution1, solution2 and so forth) to include them in a single class.
- Added more test cases (besides those originally given), including extreme ones to avoid long execution times.
- For a more in-depth understanding of the implemented code, as many comments as possible have been included.
- No intention of winning the code-of-the-year championship; readability was weighted over micro-optimization.
Test | Challenge name | Input data type | Output data type | Testing Status |
---|---|---|---|---|
1 | Square Supplies |
int | int | ✔ |
2 | Zombit Monitoring |
int[ ][ ] | int | ✔ |
3 | Palindrome |
int | int | ✔ |
4 | Zombit Antidote |
int[ ][ ] | int | ✔ |
5 | Please Pass The Coded Messages |
int[ ] | String | ✔ |
6 | Re-ID |
int | String | ✔ |
7 | Zombit Infection |
int[ ][ ], int, int, int | int[ ][ ] | ✔ |
Used annotations
@Nested
(allowing to test several outer classes (challenges), actually inside the same main test class).@ParameterizedTest
(addressing the run of same test passing several groups of parameters).@CsvSource
(arguments source, as strings &/or ints).@ValueSource
(arguments source, as strings or ints).@MethodSource
(arguments source, as multidimensional arrays of ints).@TestInstance
(PER_CLASS; enabling one single instance of the test class reusable for all method).@Order
(just for the sake of completeness, highly discouraged; switching the timeout test execution for the last).@DisplayName
(on classes & methods; see left figure).@EnabledIf
(allowing to skip a test if a true condition is not satisfied; see right figure).@BeforeEach
(displaying on screen the timestamp & test info; see bottom figure).@Tag
(identifies each test class for display info purposes).
Implemented utility methods
assertEquals
(checking against expected; input as int || String).assertArrayEquals
(checking against expected; input as multidimensional arrays, int[ ][ ]).assertTimeout
(seeking for timeout errors).assertTrue
(rejecting null & strings, including empty values).arguments.of(Object ...)
(input source; as multidimensional arrays of ints or strings).
Distributed under the MIT License. See LICENSE.txt
for more information.