DIG1108C Lesson 7 Fall 2014

6

Click here to load reader

description

Valencia College DIG1108C Lesson 7 Fall 2014

Transcript of DIG1108C Lesson 7 Fall 2014

Page 1: DIG1108C Lesson 7 Fall 2014

Intro to Server Side Programming

Week Seven

Page 2: DIG1108C Lesson 7 Fall 2014

Review - Functions

• Functions must start with the function keyword, must contain a valid function identifier (with variables), provide an optional list of arguments surrounded by parentheses, even if there are none, and a block of code: function do_something( $an_argument, $another ) { // Code goes here }

• Nothing from outside is visible to code in the block

• Nothing inside the block is visible outside the function

• Pass values into a function as arguments at invocation: do_something( 'some value', "$another_value );

Page 3: DIG1108C Lesson 7 Fall 2014

Assertion Testing

• An assertion is a predicate (true-false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place.

• Programmers can use assertions to help specify programs and to reason about program correctness

• A precondition- an assertion placed at the beginning of a section of code, determines the set of states under which the programmer expects the code to execute

• A postcondition - placed at the end - describes the expected state at the end of execution

Page 4: DIG1108C Lesson 7 Fall 2014

Software Testing

• Software testing is the process of validating and verifying that the software:

• meets requirements that guided its design and development

• works as expected (produces the desired outputs/behavior)

• satisfies the needs of stakeholders

• Automated testing is the process of writing software that performs automated, repeatable isolated tests on a completely separate software system called the System Under Test (SUT)

Page 5: DIG1108C Lesson 7 Fall 2014

Types of Testing

• Assertion testing - is this statement correct? Can it be incorrect?

• Unit testing - does this function produce the expected output?

• Functional testing - does this module provide the expected functionality?

• Integration testing - do these modules work together?

• System testing - can we run this software where we need it?

• Validation testing - does it do what we said that it was supposed to do?

• Acceptance testing - is it actually useful to the intended users?

• Regression testing - now that we fixed something what else did we break?

Page 6: DIG1108C Lesson 7 Fall 2014

Test-Driven Development

• Test-driven development is a software development process that relies on the repetition of a very short development cycle. The developer writes an automated test case that defines a desired improvement or function, then produces the minimum amount of code to pass that test and finally refactors the new code to acceptable standards 1. Write code that describes a function that would be desirable to have but does not yet exist 2. Run the tests to generate feedback and observe3. Write some code that attempts to provide the function4. Run the tests to generate feedback. Note failures and continue to write code to produce a success5. Repeat as necessary