Skip to content
Snippets Groups Projects
Commit 73950527 authored by HSoreide's avatar HSoreide
Browse files

Add unit tests to Income and Expense classes

parent f0ef08ed
No related branches found
No related tags found
1 merge request!3Hs item class
Pipeline #202361 passed
package no.ntnu.idatt1002.demo.data;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class ExpenseTest {
@Test
@DisplayName("The Expense constructor throws exceptions when it should.")
void constructorThrows(){
assertThrows(IllegalArgumentException.class, () -> new Expense("description", 8.5f, false, null));
assertThrows(IllegalArgumentException.class, () -> new Expense("description", -10.0f, false, ExpenseCategory.BOOKS));
};
@Test
@DisplayName("The Expense constructor does not throw exceptions when it should not.")
void constructorDoesThrow() {
assertDoesNotThrow(() -> new Expense("description", 59.9f, false, ExpenseCategory.BOOKS));
}
}
\ No newline at end of file
package no.ntnu.idatt1002.demo.data;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class IncomeTest {
@Test
@DisplayName("The Income constructor throws exceptions when it should.")
void constructorThrows(){
assertThrows(IllegalArgumentException.class, () -> new Income("description", 8.5f, false, null));
assertThrows(IllegalArgumentException.class, () -> new Income("description", -10.0f, false, IncomeCategory.SALARY));
};
@Test
@DisplayName("The Income constructor does not throw exceptions when it should not.")
void constructorDoesThrow() {
assertDoesNotThrow(() -> new Income("description", 59.9f, false, IncomeCategory.SALARY));
}
}
\ No newline at end of file
......@@ -10,8 +10,8 @@ class ItemTest {
@Test
@DisplayName("The Item constructor throws exceptions when it should.")
void constructorThrows(){
assertThrows(IllegalArgumentException.class, () -> new Item("description", 89.9f, true));
assertThrows(IllegalArgumentException.class, () -> new Item("description", 0f, false));
assertThrows(IllegalArgumentException.class, () -> new Item("description", -10.0f, false));
};
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment