Skip to content
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

EmployeesMvc | New logic for creating test data #92

Open
alexeysp11 opened this issue Jul 22, 2024 · 1 comment
Open

EmployeesMvc | New logic for creating test data #92

alexeysp11 opened this issue Jul 22, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request Examples Changes related to library usage examples Shared.Models.Business Changes related to the object model for business inside the core

Comments

@alexeysp11
Copy link
Owner

alexeysp11 commented Jul 22, 2024

Description

Background

In the current implementation of the application, data is generated randomly and stored in the application memory at runtime. This requirement was probably put forward for the following reasons:

  • Avoid junk records the main database.
  • Simplifying the verification process: random generation can simplify the process, since there will be no need to manually prepare the data, and this will allow you to verify the application logic without additional manipulations.

However, creating realistic proportions between different positions and departments can significantly complicate the generation algorithm. For example, it is obvious that there should be different proportions between different positions and departments: there are always more subordinates than managers; the number of employees in the development department may also differ from the number in the accounting/finance/production department. Accordingly, creating realistic proportions will require very fine-tuning the generation algorithm to take into account the proportions between departments/positions by the number of employees; in turn, this significantly complicates the requirements for the problem.

Accordingly, using pre-prepared data via SQL script may be a more reasonable solution in this situation. This will allow you to focus on other aspects of the application, such as implementing business logic and UI.

However, you should not completely abandon the random generation algorithm for the following reasons related to application testing:

  • Universality: Randomly generated data can be used to test various scenarios without having to manually prepare data.
  • Test isolation: Each application run will work with a unique set of data, which allows you to avoid problems with the state of data between runs.
  • Simulation of real cases: Data generation can help identify errors in the application logic that may appear only under certain conditions.

Description of required actions

Main application:

  • Done: Create a separate database for testing this application (e.g. employeesmvc_test).
  • Analyze the proportions of the number of employees associated with a specific position or department.
  • Use classes from workflow-lib for the object model.
  • Each employee has the following data: full name, gender, date of birth, position, department, date of hiring.
  • Generate a SQL query to fill in the data.
  • Use EF Core to communicate with the database.
  • Remove settings related to the data generation algorithm from the configuration file of the main application (e.g. the minimum and maximum number of employees who can occupy a particular position, total number of employees, etc.). These settings are only needed for testing.
  • Rewrite project requirements in README.md.

Unit tests:

  • Instead of communicating with the database, it is necessary to use mock classes that will implement the data generation algorithm using configuration files.
  • The current algorithm for generating data for test scenarios already satisfies the minimum testing requirements, so at the moment no additional work is planned to improve the algorithm. It is only necessary to transfer the current employee generation logic to the test project.
@alexeysp11 alexeysp11 added the enhancement New feature or request label Jul 22, 2024
@alexeysp11 alexeysp11 self-assigned this Jul 22, 2024
@alexeysp11 alexeysp11 changed the title Create new logic for assigning employee to department in EmployeesMvc New logic for creating test data in EmployeesMvc Aug 17, 2024
@alexeysp11 alexeysp11 added Shared.Models.Business Changes related to the object model for business inside the core Examples Changes related to library usage examples labels Aug 17, 2024
@alexeysp11 alexeysp11 changed the title New logic for creating test data in EmployeesMvc EmployeesMvc - New logic for creating test data Aug 17, 2024
@alexeysp11 alexeysp11 changed the title EmployeesMvc - New logic for creating test data EmployeesMvc. New logic for creating test data Aug 17, 2024
@alexeysp11 alexeysp11 changed the title EmployeesMvc. New logic for creating test data EmployeesMvc | New logic for creating test data Aug 17, 2024
@alexeysp11
Copy link
Owner Author

alexeysp11 commented Sep 7, 2024

Filling positions in organizations:

  • Done: TechnoSoft
  • Done: FinanceInvest
  • Affordable Construction
  • Media Group
  • AutoTechCenter

After filling in the data for organizations, do the following:

  • In the EmployeesMvc application, create a way to view the structure of each organization: organization name, departments, teams, positions.
  • From the table of departments and teams, you can go to the "Details" page, which contains the name of the organizational element, description, manager's position and a list of employee positions.
  • If inconsistent data is found related to department and team managers, you need to correct the SQL script and correct the data in the DB.
  • If the data is displayed correctly, then continue generating data to fill in employees. To begin with, you can create only managers (to test the correctness of the relationships between tables and objects).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Examples Changes related to library usage examples Shared.Models.Business Changes related to the object model for business inside the core
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant