Podcast
Questions and Answers
What is the purpose of formulating a unit test plan in programming?
What is the purpose of formulating a unit test plan in programming?
Which of the following actions is part of the testing process with MSTest?
Which of the following actions is part of the testing process with MSTest?
What is a benefit of using data-driven tests in programming?
What is a benefit of using data-driven tests in programming?
Which aspect can be verified by a method in unit testing?
Which aspect can be verified by a method in unit testing?
Signup and view all the answers
What is the role of exceptions in unit testing?
What is the role of exceptions in unit testing?
Signup and view all the answers
What happens during stack unwinding when an exception is thrown?
What happens during stack unwinding when an exception is thrown?
Signup and view all the answers
What does the 'finally' block do in exception handling?
What does the 'finally' block do in exception handling?
Signup and view all the answers
When is the 'using' statement particularly beneficial?
When is the 'using' statement particularly beneficial?
Signup and view all the answers
Which approach is recommended when expecting unusual or invalid values?
Which approach is recommended when expecting unusual or invalid values?
Signup and view all the answers
What is a potential performance characteristic of code with exceptions?
What is a potential performance characteristic of code with exceptions?
Signup and view all the answers
What happens if there is no exception handler in MethodB for a thrown exception?
What happens if there is no exception handler in MethodB for a thrown exception?
Signup and view all the answers
How can cleanup methods be assured execution during exception handling?
How can cleanup methods be assured execution during exception handling?
Signup and view all the answers
What is the significance of having exception handlers in methods?
What is the significance of having exception handlers in methods?
Signup and view all the answers
What is the main purpose of a test plan?
What is the main purpose of a test plan?
Signup and view all the answers
Which of the following should NOT be included in a unit test plan?
Which of the following should NOT be included in a unit test plan?
Signup and view all the answers
What is meant by 'expected outcome' in a test plan?
What is meant by 'expected outcome' in a test plan?
Signup and view all the answers
How should the test categories in a unit test plan be characterized?
How should the test categories in a unit test plan be characterized?
Signup and view all the answers
What type of data should be included in the 'setup' section of a unit test plan?
What type of data should be included in the 'setup' section of a unit test plan?
Signup and view all the answers
What should the 'status' column in a unit test plan indicate?
What should the 'status' column in a unit test plan indicate?
Signup and view all the answers
To properly organize tests in the test plan, what types of test categories are typically used?
To properly organize tests in the test plan, what types of test categories are typically used?
Signup and view all the answers
Why is it important for the expected outcome to be measurable in a test plan?
Why is it important for the expected outcome to be measurable in a test plan?
Signup and view all the answers
What is the primary purpose of MSTest?
What is the primary purpose of MSTest?
Signup and view all the answers
Which attribute is used to indicate that a method is a unit test?
Which attribute is used to indicate that a method is a unit test?
Signup and view all the answers
What is indicated by the TestInitialize attribute in MSTest?
What is indicated by the TestInitialize attribute in MSTest?
Signup and view all the answers
Which method is used to compare the actual output with the expected output in a unit test?
Which method is used to compare the actual output with the expected output in a unit test?
Signup and view all the answers
What does the DataTestMethod attribute signify in MSTest?
What does the DataTestMethod attribute signify in MSTest?
Signup and view all the answers
Which attribute allows you to categorize unit tests in MSTest?
Which attribute allows you to categorize unit tests in MSTest?
Signup and view all the answers
What is the role of DataRow in MSTest?
What is the role of DataRow in MSTest?
Signup and view all the answers
What does the Timeout attribute specify in MSTest?
What does the Timeout attribute specify in MSTest?
Signup and view all the answers
What is a primary advantage of using exceptions over traditional error handling?
What is a primary advantage of using exceptions over traditional error handling?
Signup and view all the answers
Which of the following statements is true regarding the use of exceptions?
Which of the following statements is true regarding the use of exceptions?
Signup and view all the answers
What complicates the traditional error handling process when dealing with deep call stacks?
What complicates the traditional error handling process when dealing with deep call stacks?
Signup and view all the answers
What are exceptions generally regarded as?
What are exceptions generally regarded as?
Signup and view all the answers
What is one of the pitfalls of misusing exceptions?
What is one of the pitfalls of misusing exceptions?
Signup and view all the answers
What is a feature provided by exception handling specific to C#?
What is a feature provided by exception handling specific to C#?
Signup and view all the answers
When exceptions occur, what happens to the call stack?
When exceptions occur, what happens to the call stack?
Signup and view all the answers
Which of the following is a disadvantage of traditional error handling?
Which of the following is a disadvantage of traditional error handling?
Signup and view all the answers
What is implied as a benefit of properly using exceptions?
What is implied as a benefit of properly using exceptions?
Signup and view all the answers
What happens when an exception is thrown in a constructor?
What happens when an exception is thrown in a constructor?
Signup and view all the answers
What is the primary focus during the requirement discovery phase of software development?
What is the primary focus during the requirement discovery phase of software development?
Signup and view all the answers
Which of the following statements best describes non-functional requirements?
Which of the following statements best describes non-functional requirements?
Signup and view all the answers
In the analysis phase, what do the identified nouns and verbs represent?
In the analysis phase, what do the identified nouns and verbs represent?
Signup and view all the answers
What should a developer do when deciding on exception handling?
What should a developer do when deciding on exception handling?
Signup and view all the answers
Which phase of the software development life cycle involves delivering the finished system?
Which phase of the software development life cycle involves delivering the finished system?
Signup and view all the answers
What is a common goal during the testing phase of software development?
What is a common goal during the testing phase of software development?
Signup and view all the answers
What is indicated by the statement '90% of the system’s lifespan will be spent on maintenance'?
What is indicated by the statement '90% of the system’s lifespan will be spent on maintenance'?
Signup and view all the answers
What happens during the implementation phase of the software development life cycle?
What happens during the implementation phase of the software development life cycle?
Signup and view all the answers
Study Notes
Testing Principles
- Testing is a process to evaluate applications ensuring compliance with requirements.
- Testing involves systematically identifying potential issues and creating tests to verify behaviour.
- Testing helps discover, eliminate defects, and identify performance problems.
- Testing provides an objective assessment of the product's fit to requirements.
- If errors are found after delivery, tests can be created to reproduce issues and validate corrections.
- Limitations of testing include constraints on predicting error conditions and exhaustive testing of complex programs.
Alternatives to Testing
- Static analysis: Checks the source code for vulnerabilities and errors (e.g., memory leaks, buffer overruns).
- Model checking: Validates application behaviour against a pre-defined mathematical model.
- Code reviews: Reviewing code by other developers to find defects, security issues, or performance problems.
- Pair programming: Simultaneous coding and review, helping prevent logic errors.
Kinds of Testing (Part 1)
- Unit testing: Tests individual components (e.g., methods, classes) in isolation to ensure correctness.
- Different unit test types: Black box (specifies and contracts, not implementation), glass box (examines the implementation's code).
- Integration testing: Tests combined components to check interactions.
- System testing: Validates the entire system's functionality and non-functional requirements (e.g., performance, security).
Kinds of Testing (Part 2)
- Acceptance testing: Determines if the system meets customer requirements.
- Regression testing: Verifies that changes in the code do not introduce new defects.
- Performance testing: Assesses the system's response to different workloads and conditions.
- Security testing: Identifies vulnerabilities such as buffer overruns, SQL injection, or cross-site scripting.
Test Plan (General Idea)
- Test plans outline the testing process.
- It details testing objectives, scope, approach, schedule, and testing procedures.
- Provides a structured "blueprint" for a testing process.
- Specifies what will be tested, what will not, and the procedures.
Test Plan (Unit Testing)
- Test plans are usually in table format.
- Key columns include: unique test identifier (test number); concise test description; tagging for organisation (e.g., boundary, valid); detailed instructions for test setup; expected outcome details; status (Pass/Fail).
MSTest Overview
- MSTest is a unit testing framework included in Visual Studio.
- This framework automates unit tests in Visual Studio.
- The framework offers a namespace (Microsoft.VisualStudio.TestTools.UnitTesting) with classes and attributes used to code and execute tests.
MSTest Attributes
-
TestClass
: Specifies a class containing unit tests. -
TestMethod
: Designates a method as a unit test. -
TestCategory
: Categorises a unit test to group and manage tests effectively. -
TestInitialize
: Executes before each test in the class. -
ExpectedException
: Asserts an expected exception is thrown during testing. -
Timeout
: Sets a time limit for a unit test. -
DataTestMethod
: Executes a unit test with different input. -
DataRow
: Supplies input data to theDataTestMethod
.
General Structure of a Unit Test
- Setup phase: Initializes objects and establishes test conditions.
- Run phase: Executes the code under test.
- Assert phase: Verifies results against predicted outcomes.
Case Study 1: Income Tax
- This case study illustrates unit testing methodology for functions.
- Test plans are developed to cover various scenarios of input to verify the expected outcome produced (including negative input values).
- Test types are designed, considering boundary conditions and typical usage in test setup.
Case Study 2: Collection Example
- Demonstrates unit testing for classes and their methods with various input values.
- The study validates if the implementation of a class's methods meets the expected outcomes and conditions.
Testing the Collection Example
- This case study focuses on the procedures needed to test a collection.
- The code shows how to perform testing of methods (e.g., constructor and
Add
method) on collections.
Testing the Constructor
- The test plan ensures that the constructor correctly establishes collections following the expected capacity and size conditions.
Testing the Add Method
- The add method will be tested under various circumstances, ensuring consistency in the addition of items.
Testing the Minimum Method
- This method checks that the minimum value is calculated correctly in various collection conditions.
- The test plan would need to account for empty collections, collections with one item, collections with multiple items, collections starting/ending/in the middle with the minimum and collections with multiples of the minimum value.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Explore the fundamental principles of software testing and its alternatives. This quiz covers methods such as static analysis, model checking, and code reviews, highlighting their roles in ensuring application quality. Test your understanding of testing methodologies and practices in software development.