Sebastien ๐ป Garcia
Lead Developer chez Travaux.com/Instapro Group
- Report this post
I just saw someone talking about not using In Memory implementation for the DB in integration tests.And I think that requires a little global reminder :- ALL your tests must test the BUSINESS logic. Nothing else. No one cares that the method "save" was called once. But we do care that the user was created properly.- Your unit tests are NOT here to test your class. It tests the logic implementation of your business. It can be an aggregate : as long as there is a business logic, you test it using a unit test. You should test by creating your class manually and use test doubles for your dependencies, avoiding the mocks as much as possible as they have several unwanted risks.- Your integration tests are here to test your business against a code you don't own. You use a dependency injection component ? Test your business using it. You use an ORM with a MySQL implementation in production ? Do the same in the integration tests.And remember: always test the BUSINESS, not your code. It ensures that your application does what it is supposed to AND serves as a documentation.-----Code as if the next person reading your code is a psychopath who knows where you live. Most of the time, it's you in 3 months.
2
To view or add a comment, sign in
More Relevant Posts
-
Daniel Mallott
Head of Platform and Infrastructure @ e-conomic
- Report this post
Should you unit test your database code? Of course you should! I've just written a post outlining two approaches to SQL Server unit testing - one manual, and one using tSQLt.Check it out here: https://lnkd.in/dcPxWTFDShout out to Brent Ozar for the Stack Overflow database, and Bob Ward for kicking me in the rear to actually turn this conference talk into a blog post.
40
1 Comment
Like CommentTo view or add a comment, sign in
-
Maria Zulfiqar
Technical Lead (.Net) @DPL | .Net Expert | Senior Full Stack Software Engineer | Provide Technical Solutions to businesses from 11 Years. i love to play with code & enhance it, make it memory efficient :)
- Report this post
๐๐ก๐ ๐๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ ๐ฉ๐๐ญ๐ญ๐๐ซ๐ง ๐ฆ๐๐ค๐๐ฌ ๐ข๐ญ ๐๐๐ฌ๐ข๐๐ซ ๐ญ๐จ ๐ญ๐๐ฌ๐ญ ๐ฒ๐จ๐ฎ๐ซ ๐๐ฉ๐ฉ๐ฅ๐ข๐๐๐ญ๐ข๐จ๐ง ๐ฅ๐จ๐ ๐ข๐!โ It allows you to easily test your application with unit tests.โPlace the repository interfaces in the domain model layer so Web API doesnโt depend directly on infrastructure layer( actual repository classes)โ You can implement mock repositories that return fake data instead of data from the database.This decoupled approach allows you to create & run unit tests that focus the logic of your application without requiring connectivity to the database๐๐ฎ๐ง๐ง๐ข๐ง๐ ๐ก๐ฎ๐ง๐๐ซ๐๐๐ฌ ๐จ๐ ๐ญ๐๐ฌ๐ญ๐ฌ ๐๐ ๐๐ข๐ง๐ฌ๐ญ ๐ ๐๐๐ญ๐๐๐๐ฌ๐ ๐ข๐ฌ ๐๐๐ ๐๐จ๐ซ ๐ญ๐ฐ๐จ ๐ซ๐๐๐ฌ๐จ๐ง๐ฌ.โ First It can take a long time because of the large number of tests.โ Second, the database records might change and impact the results of your tests
19
11 Comments
Like CommentTo view or add a comment, sign in
-
Milad Cheriki
Software Engineer | Former VP of Engineering | .NET Expert | Tech Leadership | Code Artisan
- Report this post
Leverage the power of EF Core Migration Bundles for an enhanced approach to managing and streamlining your database migrations. When used in tandem with Helm charts, migrations can be seamlessly integrated into your CI/CD pipeline, resulting in simplified deployments and minimized potential conflicts.Discover the key benefits of using EF Core Migration Bundles:- Consolidation of all pending migrations into a single executable- Streamlined application deployment- Reduced risk of conflicts in the migration process- Greater manageability and oversightThese tools are an indispensable addition to your software development toolkit, driving efficiency and reliability in your database migration process. It's time to unleash the potential of EF Core Migration Bundles and Helm charts in your projects.EF Core Migration Bundles: https://lnkd.in/dz3J5tzU#EFCore #DatabaseMigration #MigrationBundles
26
Like CommentTo view or add a comment, sign in
-
Steve โardalisโ Smith โ
I help financial services companies beat their competitors with technology.
- Report this post
Regardless of whether your C# entities are written first or the database is, somewhere you need to have mapping information to let Entity Framework know how it should store and retrieve data representing them.https://bit.ly/3X2yNPd#efcore
22
3 Comments
Like CommentTo view or add a comment, sign in
-
Karan Gill
Student at National Institute of Technology Hamirpur
- Report this post
I'm here to share a latest update in our ongoing project aimed at enhancing data management efficiency. Our latest focus has been on empowering admin users to effortlessly update website information using a simple CSV upload feature directly from the frontend.Through the seamless integration of Multer middleware, we've revolutionized the process of updating website content. Admin users can now upload CSV files containing the latest information directly through the frontend interface, eliminating the need for complex manual interventions via Postman or backend scripts.This enhancement not only simplifies the data update process but also significantly enhances the user experience, allowing admins to make quick updates without relying on technical expertise or backend access.The true game-changer in this update is by CSV parsing tool, which efficiently converts the uploaded CSV data into JSON format. This streamlined conversion process ensures seamless integration with our database, enabling real-time updates to website content.
10
1 Comment
Like CommentTo view or add a comment, sign in
-
Aymen FARHANI
- Report this post
#springframework #transactionmanagement *) What is a transaction?A transaction refers to a set of related operations that are performed as a single unit of work. It ensures that all or none of the operations are completed successfully. Transactions are useful when multiple database operations need to be performed together, and if any error occurs during the transaction, it can be rolled back to restore the initial state.*) How @Transactional works in Spring?@Transactional is an annotation provided by the Spring framework. It is used to define the transactional behavior for methods or classes.When @Transactional is added to a method or class, Spring wraps the method or class within a transaction. This means that if an exception is thrown during the execution of the method, the transaction will be rolled back and any changes made within the method will be reverted.Transactional behavior can be configured using various attributes of @Transactional, such as isolation level, propagation behavior, rollback rules, and timeout. These attributes can be used to control the behavior of transactions according to specific requirements.In Spring, @Transactional works based on proxies. Spring dynamically generates a proxy implementation for the transactional bean and intercepts the method calls. It then applies the transactional behavior before and after the method execution.To use @Transactional in Spring, you need to enable transaction management by either using the @EnableTransactionManagement annotation or configuring it in XML-based configuration. Once enabled, you can annotate any method or class with @Transactional to enable transactional behavior.
10
Like CommentTo view or add a comment, sign in
-
Matthew Arnold
Pro Match Insights: Transforming Trades Recruitment and Lead Generation
- Report this post
Part II - The following is the remaining list of misc. software code functions in order of which they're typically produced:26. **Search Functionality:** Implementing search features based on user queries.27. **Encryption/Decryption Logic:** Implementing algorithms for data security.28. **Data Serialization/Deserialization:** Converting data to and from different formats (e.g., JSON, XML).29. **Dependency Management:** Managing external dependencies and libraries.30. **Configuration Setup:** Establishing basic settings and configurations for the software.31. **Middleware Configuration:** Configuring middleware for handling cross-cutting concerns.32. **Code Documentation:** Writing documentation for the codebase.33. **Testing Code:** Writing tests to ensure the functionality and reliability of the software.34. **Logging Configuration:** Setting up logging for tracking events and errors.35. **Concurrency Control:** Managing and handling concurrent execution of code.36. **Error Handling:** Implementing mechanisms to handle errors gracefully.37. **Transaction Handling:** Managing transactions to ensure data consistency.
Like CommentTo view or add a comment, sign in
-
Real Python
206,963 followers
- Report this post
๐๐ฐ What Are CRUD Operations?CRUD operations are the cornerstone of application functionality. Whether you access a database or interact with a REST API, you usually want to create, retrieve, update, and delete data. In this tutorial, you'll explore how CRUD operations work in practicehttps://buff.ly/3KjLvno
31
Like CommentTo view or add a comment, sign in
-
Sabbir Siddiqui
Senior Engineering Manager @ Optimizely
- Report this post
When I am building any API, these are the top 4 things I try to always consider regardless of the language or framework (or requirements):1. Request validation - Query, path or body json parameters - all should be validated through some standard schema or validation mechanism supported by your framework for consistent checking and error messages. This is not only for the request layer, but internally while implementing business logic, it's important to validate nulls or undefined values.2. Security - Usually authentication and authorization are handled by middleware, but sometimes business logic dictates the permission level of the API. For example, you have to query some data and return only the relevant data filtered by the user ID of the request (authenticated) user, on top of checking authorization. (AKA row level auth)3. Error handling - Unhandled exceptions should be managed through some central error handler in your framework, but otherwise business logic specific error handling should be considered. For those scenarios having custom exceptions kept in a central location can help manage all the possible exceptions your system can throw. 4. Logging - Request and response logging can be done at the framework level with some middleware (with some request ID for tracing). For API specific logging or error tracing, it's important to log key information that can help identify specific errors or steps in the logic. If possible include the request ID as a log prefix (this can also be done from a framework level).There are a bunch more things to keep in mind like proper status codes, caching, rate limiting, documentation etc some of which are handled by the framework by default, and others depending on the scenario.What other aspects are important to you while building APIs? Comment below!Please like and repost if you found this useful!#restapi #softwareengineering #bestpractices #softwaredevelopment #apibestpractices
292
51 Comments
Like CommentTo view or add a comment, sign in
-
Chathura Rupasinghe
Assistant Vice President at OCBC
- Report this post
Importance of automated tests!!
4
Like CommentTo view or add a comment, sign in
655 followers
- 99 Posts
View Profile
FollowExplore topics
- Sales
- Marketing
- Business Administration
- HR Management
- Content Management
- Engineering
- Soft Skills
- See All