-
Notifications
You must be signed in to change notification settings - Fork 56
Unit Testing Project Completion #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 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.