Download presentation
Presentation is loading. Please wait.
Published byMiles Roger Malone Modified over 9 years ago
1
BIT 142:Programming & Data Structures in C#
2
How To Use NUnit-based Starter Projects
3
BIT 142: Intermediate Programming3 NUnit / Unit Testing Unit test: –“To write test cases for every non-trivial function or method in the module so that each test case is [as] separate from the others [as] possible.” www.discovercomputers.info/ComputerSecu rity/glossary.html www.discovercomputers.info/ComputerSecu rity/glossary.html
4
BIT 142: Intermediate Programming4 NUnit / Unit Testing public bool isPrime( int num) { /*implementation omitted*/ }
5
BIT 142: Intermediate Programming5 Demo: Quick walkthrough of how to use this –(Normal console, GUI, grade gen) Things you’ll need / find useful: –To select which project will be run: Right-click on a PROJECT, then select "Set Startup Project" –Edit Find And Replace Find In Files This will let you search ALL files for a particular string
6
BIT 142: Intermediate Programming6 Details: Normal Console Program Select “PCE_StudentCode” as startup project & run like normal The 'split file' thing: –Program.cs contains Main() –PCE_09.cs contains the code you’ll implement Because the test code is in another project, you MUST make your classes PUBLIC in the StudentCode project
7
BIT 142: Intermediate Programming7 Located in the PCE_ForTests project, inside the PCE_Test.cs file You should never need to change or modify these –We’ll go through them now, briefly, in order to make sure you’ve gotten a quick overview of how the NUnit tests work. –If you need to disable a test, you can just comment the whole method out, and the rest of the system *should* just work Details: NUnit tests
8
BIT 142: Intermediate Programming8 Note about the 'EqualsFuzzy' method: –These numbers should be good, but contact me if you think they’re off for your implementation Details: NUnit tests
9
BIT 142: Intermediate Programming9 Select “PCE_Test_Runner” as startup project –Make sure that in RunTests.cs, the line int doThis = RUN_TEST_IN_GUI; is uncommented –Run in VS, then click the ‘Run’ button in Nunit –NUnit should auto-reload the code when you recompile Details: GUI Test Runner
10
BIT 142: Intermediate Programming10 Be careful about which test(s) you’ve selected Note the ‘Text Output' tab –Especially for the BubbleSort exercise –Since the BubbleSort uses randomly generated arrays, you may not get the same array twice Details: GUI Test Runner
11
BIT 142: Intermediate Programming11 Select “PCE_Test_Runner” as startup project –Make sure that in RunTests.cs, the line int doThis = RUN_TESTS_UNDER_DEBUGGER; is uncommented –Put a breakpoint in the test (or your code) –Run in VS you MUST choose Debug Start Debugging –Useful features: Step, Step Into, Step Out Watch windows Details: Using The Debugger
12
BIT 142: Intermediate Programming12 Select “PCE_Test_Runner” as startup project –Make sure that in RunTests.cs, the line int doThis = PRODUCE_GRADESHEET; is uncommented –Run in VS –Everything should run, and the gradesheet should pop up in a web browser Details: Generating A Gradesheet
13
BIT 142: Intermediate Programming13 Note about grading output: –Not all tests that you can see in the GUI are graded –Failed tests are big, but passed tests are kinda small & on the bottom Details: Using The Debugger
14
BIT 142: Intermediate Programming14 Note that compromising the system in any way will get you a zero –Hacking/changing/disabling tests –WRITING CODE TO PASS A TEST, DESPITE NOT ACCOMPLISHING IT’S REAL GOAL Ex: A ‘FindInArray’ method that just asks “Did I get asked to find the value 8? If so, return true”, so that it passes the test which asks “Is 8 in the array?” Details: Generating A Gradesheet
15
BIT 142: Intermediate Programming15 Note about grading output: –Not all tests that you can see in the GUI are graded –Failed tests are big, but passed tests are kinda small & on the bottom Details: Generating A Gradesheet
16
BIT 142: Intermediate Programming16 Submitting Your Work Delete the directory named DELETE_THIS_and_bin_and_obj_folders DELETE bin AND obj directories!!!
17
BIT 142: Intermediate Programming17 Workflow Student Workflow: –Download starter project –Examine first exercise, in Word.DOC Figure out which tests are used in the exercise Run tests, figure out which ones have failed Write code to make one+ pass –Repeat until all tests pass Repeat until all exercises done –DELETE DIRECTORIES!!! –Hand in PCEs
18
BIT 142: Intermediate Programming18 Workflow Instructor workflow: –Run tests to get basic grade –Double-check code –Grade for feedback/ stuff that’s not auto- graded –Finalize grade & email gradesheets
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.