27.07.2013 Views

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Overview 23<br />

control structure (sequences, loops, and conditional statements) that implement our<br />

protocol, and also provide data (such as IP addresses and port numbers) used by the<br />

libraries.<br />

When an application is compiled, it references the libraries it uses: the compiler<br />

consults the library assemblies for information it needs. This command compiles<br />

the Monitor application, which uses the Server and Temperature libraries.<br />

csc /target:exe /reference:Server.dll,Temperature.dll Monitor.cs<br />

In the .NET framework, an application is an assembly that contains a main<br />

method. It has the file type exe. The application assembly does not contain the<br />

compiled code of the libraries it uses. Instead, it loads those library assemblies<br />

when it is executed. The referenced libraries must be available when the application<br />

is compiled, and again when it is executed. 1<br />

This concludes our description of the remote instrument software. Now we can<br />

describe our testing and analysis.<br />

2.6 Unit testing<br />

<strong>We</strong> begin our testing and analysis with unit testing. <strong>Testing</strong> checks software by<br />

executing it. The software that is tested is called the implementation under test<br />

(IUT). Different kinds of testing can be distinguished by the amount of software<br />

that is included in the IUT. System testing executes entire applications, such as our<br />

Logger or Monitor programs. Unit testing executes some of the parts, or units, from<br />

which applications are built. In C#, the units are classes or other types. When we<br />

are doing unit testing in the .NET framework, the IUT is a library (or libraries),<br />

such as our Client and Server libraries. Creating and running unit tests require<br />

familiarity with the source code and access to the same files and tools that the<br />

developers use. Typically, unit testing is done by the same developers who write the<br />

code.<br />

For this example we use the NUnit testing tool, the .NET member of the xUnit<br />

family that also includes JUnit (for Java), CppUnit (for C++), and several others. 2<br />

NUnit provides a library for writing tests, which defines several attributes and<br />

assertions. NUnit also provides test runner applications that execute the tests and<br />

report the results.<br />

1 There are many options for locating libraries: they can be in the same directory as the application,<br />

or in a special .NET directory called the Global Assembly Cache (GAC), or in a directory<br />

identified by one of the .NET .config files.<br />

2 Some editions of Microsoft Visual Studio include a similar unit testing tool.<br />

more free ebooks download links at:<br />

http://www.ebook-x.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!