testing Flashcards
process where developers write automated test cases before writing the actual code for their software.
Test-driven development (TDD)
In TDD, the development process is broken down into ——–, iterative steps.
small
First, a ——- is written that describes the ——– behavior of the code to be written. Then, the developer writes the code that ——– the test. If the code passes the test, the developer moves on to the ————-, writing another test for a new behavior, and then writing code to satisfy that test.
test
desired
satisfies
next iteration
Benefits of TDD
1.Early ——- detection.
2. ——— code quality
3. ———–development time
bug
Improved
Reduced
testing of the smallest testable units of code (for Java, this will be methods). and ensures that everything is running as it should
unit testing
Generally, tests can be ———— or ————- tests and you should have both.
positive
negative
with ———— tests give an we give an expected/valid input and check to see if the expected return occurs.
positive
with ————- tests we take an invalid/unexpected input and see if your code handles it correctly.
negative
a testing framework that provides annotations and methods for creating unit tests.
JUnit
used to record application events, log debugging information for developers, and write exception events to files.
What is logging
first steps for TDD.
TDD involves writing ——— tests first,
then writing the ———- amount of code necessary to pass the test,
then ———- the code.
finally the process is ————- until all of the desired functionality is implemented.
failing
minimum
refactoring
repeated
disadvantages of TDD
Forget to run tests frequently
Write too many tests at once
Write tests that are too large
Do all projects need to be tested before going live? If not, then when should testing be skipped?
yes, all projects need to be tested before going live.
This is an important part of software development, it allows developers to preserve knowledge that that can be transferred to new developers. it also makes the code base easier to read, understand and maintain, and it’s a reference new developers can look at to understand the codebase and how the code works.
what is developer documentation
————- coverage is used to test how many lines of code is being executed by tests, and can help highlighting areas of code that are not being adequately covered.
————— coverage is used to make sure that all the aspects of the software is adequately tested and measures the percentage of requirements.
code
Test
What is more important: code coverage or test coverage? Explain your answer.
Both. code coverage and test coverage are important in different ways.
Is it necessary to follow each step in the TDD process? What happens if we skip a step?
no it is not necessary but skipping a step can lead to bugs and errors that are avoidable.
What’s the difference between manual and automated testing?
——– testing involves human testers executing test cases and checking to make sure that the software’s behavior matches the expected behavior
———– testing is done buy a computer
——– testing is good large and complex systems
—– testing is good for making sure the users needs are met by the software.
Manual
automatic
automatic
manual
What’s the difference between functional and non-functional testing?
————– testing focuses on the functional requirements which is making sure the software works as expected and meets user requirements while
———– testing is used to check the non-functional requirements.
Functional testing typically involves testing the software’s ——- and output, data validation and examples include unit testing and acceptance testing. Non-functional testing typically involves testing the software’s performance, reliability, and accessibility and examples include load testing and security testing.
Functional
non-functional
Functional testing typically involves testing the software’s ——- and —–, data validation and examples include ——- testing and acceptance testing.
Non-functional testing typically involves testing the software’s ———, reliability, and accessibility and examples include ——– testing and security testing.
input
output
unit
performance
load
JUnit achieves the isolation of tests through several mechanisms:
————— = methods that set up the test environment before each test case is run.
—————- = classes that execute test cases and report the results.
—————— = used to compare expected and actual results in a test case.
————— = objects that simulate the behavior of a real object, and can be used to test code that depends on that object.
Test fixtures
Test runners
Assertion methods
Mock objects
How do you check if a test method throws Exception in JUnit?
@Test annotation and the assertThrows() method.
What are some best practices you follow while writing code to make it more testable?
1).Write ——-, focused methods:
2.)Write code that is easy to ——:
3.) Use ——– to abstract away implementation details.
4.)Write ——– code from the start:
small
understand
interfaces
testable
What is the difference between Stub and Mock in Unit testing?
——— are simpler and are used to verify the behavior of the class being tested.
———— more complex and a more powerful way to verify the behavior or the class being tested.
——- designed to mimic the behavior of dependencies
———- provide controlled input to the class being tested.
stub
mock
mock
stub