1 / 23

Testing

Testing. Especially Unit Testing. V-model. Wikipedia : http://en.wikipedia.org/wiki/V-Model_(software_development). Verification & Validation. Verification Phases Requirements analysis System Design Architecture Design Module Design Validation Phases Unit Testing

saad
Download Presentation

Testing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Testing Especially Unit Testing

  2. V-model Wikipedia: http://en.wikipedia.org/wiki/V-Model_(software_development)

  3. Verification & Validation • Verification Phases • Requirements analysis • System Design • Architecture Design • Module Design • Validation Phases • Unit Testing • Integration Testing • System Testing • User Acceptance Testing

  4. Types (or Stages) of Testing(Validation) • Developer Testing • Normal testing by the developer / programmer – to see it do work • Independent and Stakeholder Testing • Independent Testing denotes the test design and implementation that it is most appropriate for someone independent from the team of developers to do. • Unit Tests • Systematic automatic test of a unit (testing from a black box view) – our focus • Integration Test • integration testing is performed to ensure that the components in combination do work (e.g. that classes across packages do work) • System Test • System testing is done when the software is functioning as a whole. Do the whole system works • Acceptance Test • The users do the testing and accepting as a final test action prior to deploying the software. Check that all use-cases and all non-functional requirements work

  5. Unit testing • White box testing • where you check all programming lines have been executed with an accepted result • Black box testing • where you check all methods have been executed and all parameter boundaries have been checked – of cause again with an accepted result

  6. Black-box (UPedu) • input argument • Normal values from each equivalence class. • Values on the boundary of each equivalence class. • Values outside the equivalence classes. • Illegal values. • output argument • Normal values from each equivalence class. • Values on the boundary for each equivalence class. • Values outside the equivalence classes. • Illegal values.

  7. Set up test-cases • Follow / Fill out schema

  8. Example - Person • Constrains: • ID a number between 1000-99999 • Namea text which is not null and at least 4 character long • Phonea number of 8 digits

  9. Model Driven Development> Identify New Functionality Pass ImplementFunctionality and Refactor Fail Write Test Run Test

  10. Running tests in Visual Studio [TestMethod] publicvoidconvertToInt() { } publicstaticintconvertToInt(stringbinaryNumber) { thrownewNotImplementedException(); }

  11. A classthatneeds to beimplemented publicclassBinaryHelper { publicstaticboolgreaterThan(string p1, string p2) { thrownewNotImplementedException(); } publicstaticboolsmallerThan(String p1, String p2) { thrownewNotImplementedException(); }

  12. Unit tests [TestClass] publicclassBinaryHelperTest { [TestMethod] publicvoidgreaterThanTest() { } [TestMethod] publicvoidsmallerThan() { }

  13. Tool to generate first part of Unit Test • Unit Test Generator – to download and install • Link: • http://visualstudiogallery.msdn.microsoft.com/45208924-e7b0-45df-8cff-165b505a38d7 • For more information: • http://vsartesttoolingguide.codeplex.com/releases/view/102290

  14. The Assertclass

  15. The Assertclasscontinued http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.aspx

  16. Mockobjects

  17. Test Student Class

  18. Using Mockobjects

  19. Moq4 A mockobjectframework for MStest

  20. Moq4 example publicvoidCompleteCourseTest() { // setup mock activity var c = newMock<IActivity>(); c.Setup(m => m.GetName()).Returns("Programming"); c.Setup(m => m.getECTS()).Returns(15); // test with mock activity Student s = newStudent(); Assert.IsTrue(s.EnrollActivity(c.Object)); }

More Related