Unit Testing Project Completion#72
Conversation
Added detailed README for Coding Tracking Application, covering technologies, installation steps, application details, and unit tests.
chrisjamiecarter
left a comment
There was a problem hiding this comment.
Hey @JJHH17 👋,
Excellent work on your Unit Tests project submission 🎉!
I have performed a peer review. Review/ignore any comments as you wish.
💪 Great job on this project. To be honest, I would have expected you to refactor any validation methods from the original CodingTracker application into a separate Validation.cs class and then test that class and its methods.
💭 Another note: You only need the project.username (e.g. CodingTracker.JJHH17) convention at the top-level (i.e. the project level).
Your solution and csproj names can be simpler, shorter (i.e. CodingTracker and CodingTracker.Tests)
🟢 Requirements
⭐ You have fulfilled all of the project requirements!
🟠 Test Method Structure
💡 One way to improve your tests is by structuring with the Arrange Act Assert pattern. Just including these as comments forces you to think about the method a bit harder.
[TestMethod]
public void Method_ShouldReturnTrue_WhenInputIsValid()
{
// Arrange.
var input = "input"
// Act.
var result = Test.Method(input);
// Assert.
Assert.IsTrue(result);
}
🟠 Test Input
💡 Give inputs to your methods to test a wider range of scenarios:
[TestMethod]
[DataRow(-1)]
[DataRow(0)]
[DataRow(1)]
public void IsPrime_ShouldReturnFalse_WhenValuesLessThan2(int value)
{
// Arrange. (value is now passed in from DataRow into the method params)
// Act.
var result = _primeService.IsPrime(value);
// Assert.
Assert.IsFalse(result, $"{value} should not be prime");
}
🟠 Test Class Naming
💡 Mirror your production code structure and append .Tests to namespaces. Name test classes after the class being tested with Tests suffix:
💭 Example:
namespace CodingTracker.Tests
{
[TestClass]
public class ValidationTests
🟠 Test Method Naming
💡 Use clear, descriptive names that follow the pattern: MethodName_Should_ExpectedBehavior_When_StateUnderTest
💭 Example:
public void Calculate_ShouldReturnZero_WhenInputIsEmpty()
{
// Arrange
var calculator = new Calculator();
var input = new List<int>();
// Act
var result = calculator.Calculate(input);
// Assert
Assert.AreEqual(0, result);
}
I will go ahead and mark as approved, keep up the excellent work on the next projects! 😊
Best regards,
@chrisjamiecarter 👍
| } | ||
|
|
||
| [TestMethod] | ||
| public void DateInput_ValidDateFormat_PassesIfValidFormat() |
There was a problem hiding this comment.
🟠 No Value
💡 This tests nothing in your application and brings no value.
This project contains unit tests for the Coding Tracker application; the tests mainly touch on data validation, as data entered follows the DateTime object format.