Skip to content

Tests for ShoppingCart service and controller.#18

Merged
SnkvS merged 2 commits into
mainfrom
shopping_cart_test
Jun 16, 2025
Merged

Tests for ShoppingCart service and controller.#18
SnkvS merged 2 commits into
mainfrom
shopping_cart_test

Conversation

@SnkvS

@SnkvS SnkvS commented Jun 12, 2025

Copy link
Copy Markdown
Owner
Screenshot 2025-06-12 at 19 15 53

@liliia-ponomarenko liliia-ponomarenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! A few recommendation ;)

import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class ShoppingCartServiceTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use Given-When-Then construction and improve readability

Comment on lines +66 to +76
void setUp() {
user = new User();
user.setId(USER_ID);
book = new Book();
book.setId(BOOK_ID);
book.setTitle("Test Book");
book.setAuthor("Test Author");
book.setIsbn("978-3-16-148410-0");
book.setPrice(new BigDecimal("29.99"));
cartItem = new CartItem();
cartItem.setId(CART_ITEM_ID);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better move test data to the util class

@SnkvS SnkvS merged commit 17dc52c into main Jun 16, 2025
2 checks passed
@SnkvS SnkvS deleted the shopping_cart_test branch June 16, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants