Welcome to my repository for the 'Back-End Technologies Basics' course in QA Engineering at SoftUni. Here, I will be sharing my exercises.
- DataFormats
- Exercises: DataFormats
- JavaScript-Basics
- Exericses: JavaScript-Basics
- JavaScript-Fundamentals
- Exercises: JavaScript-Fundamentals
- UnitTesting with JavaScript
- Exercises: UnitTesting with JavaScript
- Databases SQL and NoSQL
- IntegrationTesting-Lab
- IntegrationTesting-Exercises-Part1
- IntegrationTesting-Exercises-Part2
- UnitTesting-with-Mocking
- RESTful-API-Testing-Execises
- Code-Coverage-JS-and-C#
- Mutation-Testing
- Added initial product data in JSON format for practical exercises.
- Products include details such as name, price, description, and keywords.
- Introduced city data in XML format representing information about various cities.
- Includes city name, country, population, and notable landmarks.
- Added country data in YAML format, providing information on countries, capitals, populations, and spoken languages.
These exercises are part of the "Data Formats" lesson, exploring JSON, XML, and YAML in the context of Back-End Technologies Basics. The datasets serve as valuable resources for hands-on learning and practical application of data formats in backend development.
In this exercise set, we explored various data formats, including JSON, XML, and YAML. The exercises involved creating and parsing data structures in each format to reinforce understanding and practical application. Here's a brief overview:
- Included book data in JSON format.
- Applied for practical exercises on nested JSON structures and data representation.
- Added student and course data in JSON format.
- Utilized for exploring complex JSON structures and relationships.
- Integrated order data in YAML format.
- Explored YAML data processing and understanding complex data structures.
- Introduced reservation data in YAML format.
- Used for hands-on exercises focusing on YAML structures and nested data.
- Added device data in XML format.
- Utilized for exploring XML parsing and processing techniques.
- Integrated vehicle data in XML format.
- Applied for practical exercises on XML parsing and transformation.
- The associated C# programs demonstrate parsing and processing of data in each format.
- Choose the desired data format exercise by running the program and following on-screen prompts.
This section covers fundamental JavaScript concepts and practices, providing a solid foundation for beginners. The exercises focus on practical scenarios, allowing learners to apply their knowledge and enhance problem-solving skills.
- Implemented a basic JavaScript function to multiply a given number by 2. This exercise serves as an introduction to writing simple functions.
- Created a function to display information about a person, including their name, age, and grade. This exercise emphasizes string interpolation and formatting in JavaScript.
- Implemented a conditional function to check if a given number is excellent. This exercise introduces basic if-else statements.
- Developed a function to convert a numerical month representation into its corresponding name. This exercise showcases the usage of switch statements.
- Introduced a function to perform various arithmetic operations based on user input. This exercise highlights the practical application of switch statements in JavaScript.
- Implemented a function to find the largest among three numbers using Math.max. This exercise emphasizes the usage of built-in functions in JavaScript.
- Created a function to calculate ticket prices based on age and type of day. This exercise demonstrates nested conditional statements.
- Introduced a function to calculate the area of a circle, given the radius. This exercise emphasizes handling different data types using typeof.
- Implemented a loop to print numbers from 1 to 5. This exercise reinforces the fundamental concept of loops in JavaScript.
- Developed a function to print numbers in reverse order within a specified range. This exercise provides hands-on experience with loops and conditional statements.
This section delves deeper into JavaScript, presenting a series of exercises that cover various aspects of the language. From conditional statements and loops to functions and logical operations.
- Implemented a function to classify individuals into different age groups based on predefined ranges. This exercise focuses on using conditional statements effectively.
- Created a function to calculate the total cost for different groups attending events on specific days. This exercise involves nested conditionals and arithmetic operations.
- Developed a function to determine if a given year is a leap year. This exercise reinforces logical operators and conditional statements.
- Implemented a function to calculate the sum of numbers within a specified range. This exercise emphasizes loop structures and basic arithmetic operations.
- Developed a function to generate and display the multiplication table for a given number. This exercise reinforces the use of loops for repetitive tasks.
- Implemented a function to calculate the sum of digits in a given number. This exercise introduces while loops and basic arithmetic operations.
- Created a function to concatenate three characters and display the resulting string. This exercise emphasizes string manipulation in JavaScript.
- Implemented a function to reverse the order of three characters. This exercise provides practice with string manipulation and array operations.
- Developed a function to calculate the total cost of purchasing a specified amount of fruit. This exercise involves basic arithmetic operations and string formatting.
- Implemented a function to check if all digits in a given number are identical. This exercise involves using loops and conditional statements for digit comparison.
- Created a function to check if a vehicle is within the speed limit based on the speed zone. This exercise demonstrates the use of if-else statements and logical operators.
- Implemented a function simulating a series of cooking operations on a numerical input. This exercise emphasizes function composition and conditional logic in a culinary context.
This section focuses on fundamental JavaScript concepts, covering exercises that explore arrays, loops, conditionals, and basic data manipulation.
- Developed a function to calculate the sum of the first and last elements of an array. This exercise introduces basic array manipulation in JavaScript.
- Implemented a function to reverse the order of elements in an array. This exercise reinforces array manipulation skills, particularly using loops.
- Created a function to calculate the difference between the sums of even and odd numbers in an array. This exercise involves loop iteration and conditional statements.
- Developed a function to extract a substring from a given text based on a specified start index and count. This exercise reinforces string manipulation in JavaScript.
- Implemented a function to censor a banned word in a text by replacing it with asterisks. This exercise introduces string replacement and loop-based string manipulation.
- Created a function to count the occurrences of a specific word in a text. This exercise involves splitting a text into words and counting using loops.
- Implemented a function to classify grades into different categories. This exercise introduces conditional statements based on grade ranges.
- Developed a function to calculate the power of a number. This exercise emphasizes using the
Math.pow
function for mathematical operations.
- Implemented a function to repeat a given string a specified number of times. This exercise involves loop iteration for string concatenation.
- Created a function to calculate the total price of a product based on its type and quantity. This exercise involves switch statements for product-specific pricing.
- Developed a function to create a person object with specified attributes. This exercise introduces object creation and initialization.
- Implemented a function to print the properties of an object. This exercise reinforces object iteration and property access.
- Developed a function to extract and print unique names and phone numbers from an array of strings. This exercise emphasizes object creation and string manipulation.
This section delves deeper into JavaScript fundamentals, covering exercises that explore array manipulation, string operations, and object handling. The exercises provide hands-on experience in practical scenarios, reinforcing core concepts.
- Developed a function to rotate the elements of an array a specified number of times. This exercise focuses on array manipulation and rotation.
- Implemented a function to select elements from an array with a specified step. This exercise reinforces array manipulation skills, particularly using loops.
- Created a function to sort an array of strings alphabetically. This exercise involves the use of the
sort
method and string comparison.
- Developed a function to rearrange an array, placing the smallest and largest elements alternatively. This exercise reinforces array sorting and manipulation.
- Implemented a function to replace specific words in a text with corresponding words from another list. This exercise introduces string replacement and array manipulation.
- Created a function to check if a specific word exists in a given text. This exercise involves string manipulation and conditional statements.
- Implemented a function to find the smallest number among three given numbers. This exercise emphasizes the use of conditional statements and mathematical operations.
- Developed a function to perform arithmetic operations based on user input. This exercise highlights practical applications of switch statements in JavaScript.
- Implemented a function to repeat a given string a specified number of times. This exercise involves loop iteration for string concatenation.
- Developed a function to validate a password based on specified criteria. This exercise introduces regular expressions and error handling.
- Implemented a function to process an array of employee names, generating additional data. This exercise emphasizes object creation and array iteration.
- Developed a function to format geographical data into objects with specific attributes. This exercise reinforces object creation and property initialization.
- Created a function to manage stock levels based on current and ordered stock data. This exercise involves object manipulation and iteration.
- Implemented a function to manage a movie database, processing commands to add details to movies. This exercise showcases object manipulation and filtering.
- Developed a function to process RPG heroes' data, sorting and displaying relevant information. This exercise emphasizes object creation, sorting, and output formatting.
- Implemented a function to find and return words with odd occurrences in a given text. This exercise involves string manipulation, word counting, and object handling.
- Developed a function to manage a parking lot, processing data for incoming and outgoing cars. This exercise demonstrates the use of a Set for efficient data management and sorting.
This section focuses on the fundamentals of unit testing in JavaScript. It covers exercises that involve writing unit tests for various functions to ensure their correctness and reliability.
- Implemented a
sum
function that calculates the sum of an array of numbers. - Created unit tests using Chai and Mocha to validate the function's behavior with different input scenarios.
- Developed an
isSymmetric
function to check if an array is symmetric. - Created unit tests to verify the function's correctness with symmetric and non-symmetric arrays, as well as edge cases.
- Implemented an
rgbToHexColor
function to convert RGB values to hexadecimal color codes. - Created comprehensive unit tests to cover various scenarios, including invalid input values and correct conversions.
- Implemented a
createCalculator
function that returns a calculator object with add, subtract, and get methods. - Developed unit tests to ensure the calculator behaves correctly with various sequences of addition and subtraction operations.
This section focuses on unit testing principles in JavaScript, emphasizing the importance of testing functions for correctness and reliability. The exercises cover writing unit tests for different functions to ensure their robustness.
- Implemented an isOddOrEven function to determine whether the length of a given string is odd or even. Created unit tests using Chai and Mocha to validate the function's behavior with various input types, including non-strings and empty strings.
- Developed a lookupChar function to retrieve a character at a specified index from a given string. Designed unit tests to ensure the function handles different scenarios, such as invalid input types, incorrect indices, and correct character retrieval.
- Created a mathEnforcer object with methods for adding five, subtracting ten, and calculating the sum of two numbers. Implemented thorough unit tests to validate the object's behavior with different input types, including strings and various numeric values.
- Implemented an analyzeArray function to calculate the minimum, maximum, and length of a numeric array. Crafted unit tests to ensure the function handles arrays with different elements, empty arrays, and arrays with identical elements correctly.
Note: Each exercise includes comprehensive unit tests using Chai and Mocha to cover a wide range of scenarios, ensuring the reliability and correctness of the implemented functions.
This section provided a comprehensive overview of databases, focusing on SQL Server Management Studio (SSMS) for SQL databases and MongoDB for NoSQL databases. Participants gained hands-on experience in executing SQL queries, covering essential CRUD operations (Create, Read, Update, Delete). Additionally, practical exercises involved working with MongoDB, including the insertion of JSON files and performing operations using MongoDB Compass. This laid the foundation for understanding fundamental database concepts and operations in both SQL and NoSQL environments.
This section delves into integration testing for the TownsApplication project, focusing on validating the functionality of the TownController class. Integration tests have been created to ensure the correctness and reliability of key operations such as adding, updating, deleting towns, handling invalid input, preventing duplicates, and listing all towns.
Project Structure:
-
Main File (Program.cs):
- Implements the console-based Town Management System.
- Utilizes the TownController for town-related operations.
-
DbContext (TownDbContext.cs):
- Defines the TownDbContext class, responsible for interacting with the in-memory database.
-
Model (Town.cs):
- Represents the Town entity with properties like Id, Name, and Population.
-
Controller (TownController.cs):
- Manages town-related operations, including adding, updating, deleting, listing, and resetting the database.
- Implements validation for town names and populations.
Integration Tests (TownControllerIntegrationTests.cs):
-
AddTown_ValidInput_ShouldAddTown:
- Tests the successful addition of a town with valid inputs.
-
AddTown_InvalidName_ShouldThrowArgumentException:
- Ensures that AddTown throws an ArgumentException for invalid town names.
-
AddTown_InvalidPopulation_ShouldThrowArgumentException:
- Validates that AddTown handles invalid population values and throws the expected exception.
-
AddTown_DuplicateTownName_DoesNotAddDuplicateTown:
- Verifies that AddTown does not add a duplicate town with the same name.
-
UpdateTown_ShouldUpdatePopulation:
- Checks if the UpdateTown method correctly updates the population of a town.
-
DeleteTown_ShouldDeleteTown:
- Tests the deletion of a town and ensures it is removed from the database.
-
ListTowns_ShouldReturnTowns:
- Validates that the ListTowns method correctly returns a list of all towns in the database.
This section covers exercises related to integration testing in the context of the LibroConsoleAPI project. Integration tests are crucial for verifying the interactions between various components of the application and ensuring that they work together as expected.
-
Integration Test Files:
AddBookMethodTests.cs
: Contains tests for adding books to the database, covering scenarios with valid and invalid input data.DeleteBookMethodTests.cs
: Focuses on testing the deletion of books from the database, including cases with valid and invalid ISBNs.GetAllBooksMethodTests.cs
: Tests the retrieval of all books from the database, handling scenarios where books exist and where none are found.GetSpecificAsyncMethodTests.cs
: Covers tests for retrieving a specific book from the database based on its ISBN, handling cases with valid and invalid ISBNs.SearchByTitleMethodTests.cs
: Tests the functionality of searching for books by their titles, considering scenarios with valid and invalid title fragments.UpdateBookMethodTests.cs
: Validates the functionality of updating book details in the database, including cases with valid and invalid input data.
-
Purpose:
- Validate the behavior of the
BookManager
class and its interaction with the database. - Ensure that CRUD (Create, Read, Update, Delete) operations on books function correctly.
- Cover edge cases and handle invalid inputs to maintain the integrity and reliability of the application.
- Validate the behavior of the
-
Technologies Used:
- C#
- xUnit testing framework
- nUnit testing framework
- Entity Framework Core for database operations
In this section, we continued our exploration of integration testing by delving deeper into testing the integration between various components of our application. We focused on testing the interactions between different layers, such as controllers, services, repositories, and the database.
-
XUnit Integration Tests:
- Implemented integration tests using XUnit framework.
- Covered CRUD operations for managing movies in the library.
- Ensured proper handling of valid and invalid movie data.
- Verified functionality for adding, deleting, updating, and retrieving movies.
- Utilized XUnit's Fact and Theory attributes for different test scenarios.
- Checked for expected exceptions and handled edge cases appropriately.
-
NUnit Integration Tests:
- Developed integration tests using NUnit framework.
- Covered similar functionalities as XUnit tests, focusing on CRUD operations for managing movies.
- Ensured proper handling of valid and invalid movie data.
- Verified functionality for adding, deleting, updating, and retrieving movies.
- Utilized NUnit's SetUp, TearDown, and OneTimeSetUp, OneTimeTearDown attributes for test setup and teardown operations.
These exercises provided hands-on experience in thoroughly testing the integration between various components of our application, ensuring robustness and reliability.
In Section 13, "Unit Testing with Mocking," you'll delve into the essential practice of unit testing with mocking techniques. Unit testing is a crucial aspect of software development, enabling you to validate individual units of code in isolation to ensure they function as expected. Mocking, on the other hand, allows you to simulate dependencies of the unit under test, providing controlled environments for testing without reliance on external resources.
-
Exercise 1: Greeting Provider Unit Testing
- Objective: The objective of this exercise is to test the
GetGreeting
method of theGreetingProvider
class, which returns a greeting message based on the current time of day. - Techniques Learned:
- Mocking the
ITimeProvider
interface using Moq to simulate different time scenarios. - Writing unit tests to verify the behavior of the
GetGreeting
method under various time conditions.
- Mocking the
- Key Concepts Covered:
- Using setup methods in Moq to define the behavior of mock objects.
- Employing assertions to verify the correctness of method outputs.
- Testing edge cases and boundary conditions to ensure comprehensive coverage.
- Objective: The objective of this exercise is to test the
-
Exercise 2: ItemRepository Unit Testing
- Objective: This exercise focuses on testing the methods of the
ItemService
class, which interacts with anItemRepository
to perform CRUD operations on items. - Techniques Learned:
- Mocking the
IItemRepository
interface to isolate theItemService
from the actual database. - Writing unit tests to cover different scenarios such as adding, updating, deleting items, and validating input.
- Mocking the
- Key Concepts Covered:
- Using Moq to mock repository interactions and simulate database behavior.
- Testing exception handling and error conditions.
- Validating input parameters and ensuring method correctness under various conditions.
- Objective: This exercise focuses on testing the methods of the
In Section 14, "RESTful API Testing," we focus on ensuring the reliability and functionality of our RESTful API endpoints. Through comprehensive testing strategies, we validate the behavior of our API methods, covering scenarios such as adding, retrieving, updating, and deleting resources.
- Writing integration tests for API endpoints using NUnit.
- Mimicking database behavior with an in-memory database for controlled testing environments.
- Applying the Arrange-Act-Assert pattern to structure test cases effectively.
- Testing various scenarios, including successful operations, error handling, and edge cases.
- Verifying the correctness of API responses and ensuring proper data manipulation.
-
EventService Integration Testing: Integration tests are created to validate the functionality of the
EventService
class, covering methods for managing events in our application. These tests ensure that events can be added, retrieved, updated, and deleted correctly, while also checking for error handling and edge cases. -
Comprehensive Test Suite: A comprehensive suite of tests is developed to assess different aspects of the API, including adding events, retrieving event details, joining and leaving events, updating events, and checking user participation. These tests help maintain the reliability and stability of the API functionality across various scenarios.
By mastering RESTful API testing techniques, we ensure that our API endpoints perform as expected, providing a robust foundation for our application's backend functionality.
In Lesson 15, we explored the concept of code coverage and its importance in ensuring the reliability and effectiveness of our codebase. We delved into techniques for measuring code coverage in both JavaScript (JS) and C# environments, leveraging tools such as NYC for JS and built-in features for C#.
- Code Coverage Fundamentals: Understanding what code coverage is and why it's crucial for assessing the quality of our code.
- JS Code Coverage with NYC: Exploring how to measure code coverage in JavaScript using the NYC (istanbul) tool, analyzing our test suite's effectiveness in covering our codebase.
- C# Code Coverage: Implementing code coverage analysis in C# projects, utilizing built-in features and tools to ensure comprehensive testing coverage.
- JavaScript Coverage: We learned how to integrate NYC into our JavaScript projects, gaining insights into the percentage of code covered by our tests and identifying areas for improvement.
- C# Coverage: Exploring code coverage within C# projects, we enhanced our testing suite to achieve higher coverage percentages, improving the overall reliability and robustness of our applications.
Code coverage serves as a critical metric in software development, indicating the proportion of our codebase that is exercised by tests. By striving for high code coverage percentages, we can increase confidence in our code's correctness, identify potential bugs early in the development cycle, and facilitate more effective maintenance and refactoring efforts.
In Lesson 16, we delved into the realm of Mutation Testing, a powerful technique used to assess the effectiveness of our unit tests by introducing small changes, or mutations, into the source code and then re-running the tests to determine if any mutations cause the tests to fail. This process helps evaluate the robustness of our test suite by identifying areas where our tests may be insufficient in detecting faults or changes in the codebase.
- Understanding Mutation Testing and its significance in software testing.
- Implementing Mutation Testing using tools like Stryker.
- Analyzing mutation reports to identify areas for improving test coverage and test effectiveness.
- Enhancing the reliability of unit tests by incorporating mutation testing into the testing workflow.
Through practical exercises and examples, we gained hands-on experience in applying mutation testing techniques to real-world codebases, allowing us to refine our testing strategies and bolster the overall quality and reliability of our software projects.