Software Engineering
What are teh different stages for manual testing ?
1. unit testing 2. integration testing 3. system testing 4. user acceptance testing
Given a function/method to test, how do we derive/generate inputs to the function/method that test its beahviour?
1.Manual Testing 2.Random Testing 3. Search-based Testing 4. symbolic execution
Error
A bad program state that results from a fault
class/object
A class is a type of a template definition of the methos and fields. An object is an instance of a class and combines data with behaviot that acts on that data
Interface
A specification of method signatures without supplying implementations, as a mechanism for enabling polymorphism
Fields
A variable inside an object that is used to store its state
Abstract class
Abstract classes allow you to define some behaviors and they force your subclasses to provide others
Why is testing hard?
Because the only way to be SURE a program has no bugs is to run all possible executions.
asserNull()
Checks that the object is null
what is a typical manual unit test?
Do something to the software that has a known result, Assert the result matches what you expect.
Why use JUnit
Easy, allows you to write code faster, runs in IDES, can be ran through command-line and Automation of tests saves time increases quality
Sources of Problems Requirements definition
Erroneous, incomplete, inconsistent requirements
Sources of Problems Design
Fundamental design flaws in the software
What are two search based optimization algorithms?
Genetic algorithm and Hill climbing
problems with symbolic execution
Path explosion and is too complex constraint
Sources of Problems Support systems
Poor programming languages, faulty compilers and debuggers, misleading development tools.
Random Testing (guess)
Randomly generate inputs to feed in a software. Does not require any preparation and is easy to implement works well in many cases
Sources of Problems Evolution
Sloppy maintenance, introduction of new flaws in attempts to fix old flaws
asserEquals()
Tests that two values are the same
Inheritance
The ability for a class to inherit commonly used state and behavior or override functionality of another class.
Fail(message)
This method is executed once, before the start of all tests
Fault
a condition that causes a program to fail in performing its required function. A fault is a pssive flaw
Failure
an observable incorrect behavior of a program as a result of an error
why not prefer static analysis in general?
because its simple and is generally limited- doesnt reference null pointers, doesnt go outside array bounds very hard/impossible to check things like "this sort routine really sorts things"
assertFalse()
checks that the boolean condition is false
assertTrue()
checks that the boolean condition is true
constructors
create and initialize the state of a new object
Test suite
grouping several test cases together
object-oriented programming
in an OOP, a software system is represented as a collection of objects that interact with each other to solve the overall problem.
Sources of Problems\ Inadequate Testing of Software
incomplete testing, poor verification, mistakes in debugging.
Search Based Software Testing (SBST)
is a branch of Search Based Software Engineering (SBSE)
unit test
is a piece of a code that invokes naother piece of code and checks the correctness of some assumptions afterward. if the assumptions turn out to be wrong , the unit test fails
Symbolic execution (deduction)
is a program analysis technique that analyzes a programs code to automatically generate test data for the program. analyzes the code structure to find out a path to to a certain statement and to find out the constraint of the inputs to let the program follow the path uses constraint solver to provide a value set that satisfies the constraint
Module testing
is designed to asses individual modules in isolation, including how the component units interact with each other and their associated data structures.
Integration testing
is designed to assess whether the interfaces between modules in a given subsystem have consistent assumptions and communicate correctly
System testing
is designed to determine whether the assembled system meets its specifications. it assumes that the peices work individually, and asks if the system works as a whole.
Acceptance testing
is designed to determine whether the completed software in fact meets these needs. In other words, acceptance testing is performed in a user environment and using real data.
Formal verification
is the process of checking whether a design satisfies some requirements
Fitness function
is used to guide a search based optimization algorithm, which searches the space of test inputs to find those that meet the test objectives
Dynamic analysis
it analyzes program code by running the program involves test cases for execution is about find and fixing defects
static analysis
it analyzes program code for all possible runtime behaviors and seeks out coding flaws ""bad patterns" without running it. can detect possible bugs in an early stage, and catch bugs without a test case- just by structure of code. can give "fasle positives" - warn you about a problem that cant actually show up when the program runs
What are some problems of SBST?
might not always find the best solution the effectiveness of the search algorithms is improved as long as the fitness function distinguishes between better and worse solutions
object methods
operations on an objects internal states and gives behavior to each object
why is unit testing important?
proper unit testing done during the development stage leads to less defect fixing costs and save both time and money in the end
Test Case
sequence of operations and inputs + assertions, and it is written in Java.
Manual Unit Tests (Think)
testing a software manually without using any automated tools or any script. the tester takes over the role of an end-user and tests the software to identify any unexpected behavior or bug.
What is one of the most important limitations of software testing
that it can only show the presence of failures not their absences.
poplymorphism
the ability to replace an object with its sub-objects to achieve different behavior from the same piece of code
Debugging
the activity by which faults are identified and rectified
Propagation
the error must persist and cause an incorrect output-a failure
Infection
the fault must actually corrupt the program state(produce an error)
Reach-ability
the test much actually reach and execute the location of the fault
@Test
this is the test method to run
@after
this method is executed after each test
@Before
this method is executed before each test
@afterClass
this method is executed once, after all test have been finished
@BeforeClass
this method is executed once, before the start of all tests
Why do we test?
we prove code is correct, using formal mathematical techniques