Test Fixtures

Test Fixtures

Download, print and study this document offline
 Page 1


Test Fixtures 
•? Provides clock 
•? Provides test vectors/checks results 
–? test vectors and results are precomputed 
–? usually read vectors from file 
•? Models system environment 
–? Complex program that simulates external environment 
•? Test fixture can all the language features 
–? initial, delays, read/write files, etc. 
Simulation 
Test Fixture 
(Specification) 
Circuit Description 
(Synthesizeable) 
Page 2


Test Fixtures 
•? Provides clock 
•? Provides test vectors/checks results 
–? test vectors and results are precomputed 
–? usually read vectors from file 
•? Models system environment 
–? Complex program that simulates external environment 
•? Test fixture can all the language features 
–? initial, delays, read/write files, etc. 
Simulation 
Test Fixture 
(Specification) 
Circuit Description 
(Synthesizeable) 
Test Fixtures 
Verilog programs used to drive the simulation 
Much easier than drawing waveforms 
Test fixtures are usually non-synthesizeable 
Anything goes!   Really is like writing a C program 
Not really Verilog! 
Self-checking text fixtures are required for regression testing 
You can write an arbitrary program in Verilog 
Page 3


Test Fixtures 
•? Provides clock 
•? Provides test vectors/checks results 
–? test vectors and results are precomputed 
–? usually read vectors from file 
•? Models system environment 
–? Complex program that simulates external environment 
•? Test fixture can all the language features 
–? initial, delays, read/write files, etc. 
Simulation 
Test Fixture 
(Specification) 
Circuit Description 
(Synthesizeable) 
Test Fixtures 
Verilog programs used to drive the simulation 
Much easier than drawing waveforms 
Test fixtures are usually non-synthesizeable 
Anything goes!   Really is like writing a C program 
Not really Verilog! 
Self-checking text fixtures are required for regression testing 
You can write an arbitrary program in Verilog 
Initial Blocks 
•? Like always blocks 
–? execute once at the very beginning of simulation 
–? not synthesizeable 
•? use reset instead 
Page 4


Test Fixtures 
•? Provides clock 
•? Provides test vectors/checks results 
–? test vectors and results are precomputed 
–? usually read vectors from file 
•? Models system environment 
–? Complex program that simulates external environment 
•? Test fixture can all the language features 
–? initial, delays, read/write files, etc. 
Simulation 
Test Fixture 
(Specification) 
Circuit Description 
(Synthesizeable) 
Test Fixtures 
Verilog programs used to drive the simulation 
Much easier than drawing waveforms 
Test fixtures are usually non-synthesizeable 
Anything goes!   Really is like writing a C program 
Not really Verilog! 
Self-checking text fixtures are required for regression testing 
You can write an arbitrary program in Verilog 
Initial Blocks 
•? Like always blocks 
–? execute once at the very beginning of simulation 
–? not synthesizeable 
•? use reset instead 
Verilog Clock Generator 
module clockGenerator (CLK); 
  parameter period = 10; 
  parameter howlong = 100; 
  output  reg CLK; 
  initial begin 
    CLK = 0; 
    #(period/2); 
    repeat (howlong) begin 
      CLK = 1; 
      #(period-period/2); 
      CLK = 0; 
      #(period/2); 
    end 
    $finish; 
  end 
endmodule 
Finishes the simulation 
Cannot be restarted 
Page 5


Test Fixtures 
•? Provides clock 
•? Provides test vectors/checks results 
–? test vectors and results are precomputed 
–? usually read vectors from file 
•? Models system environment 
–? Complex program that simulates external environment 
•? Test fixture can all the language features 
–? initial, delays, read/write files, etc. 
Simulation 
Test Fixture 
(Specification) 
Circuit Description 
(Synthesizeable) 
Test Fixtures 
Verilog programs used to drive the simulation 
Much easier than drawing waveforms 
Test fixtures are usually non-synthesizeable 
Anything goes!   Really is like writing a C program 
Not really Verilog! 
Self-checking text fixtures are required for regression testing 
You can write an arbitrary program in Verilog 
Initial Blocks 
•? Like always blocks 
–? execute once at the very beginning of simulation 
–? not synthesizeable 
•? use reset instead 
Verilog Clock Generator 
module clockGenerator (CLK); 
  parameter period = 10; 
  parameter howlong = 100; 
  output  reg CLK; 
  initial begin 
    CLK = 0; 
    #(period/2); 
    repeat (howlong) begin 
      CLK = 1; 
      #(period-period/2); 
      CLK = 0; 
      #(period/2); 
    end 
    $finish; 
  end 
endmodule 
Finishes the simulation 
Cannot be restarted 
Another Clock Generator 
module clock_gen (masterclk); 
   `define PERIOD = 10; 
 output masterclk; 
 reg    masterclk; 
 initial masterclk = 0; 
 always begin 
  #`PERIOD/2 
  masterclk = ~masterclk; 
 end 
endmodule 
use `define to make constants  
easier to find and change 
use of initial and always 
blocks 
Read More

FAQs on Test Fixtures

1. What are test fixtures in software testing?
Ans. Test fixtures in software testing are a set of preconditions or a fixed state that is defined before executing a test case or a set of test cases. These fixtures include the necessary setup, initialization, and configuration required for the test environment. Test fixtures ensure that the test cases are executed consistently and reliably, providing a known starting point for testing.
2. Why are test fixtures important in software testing?
Ans. Test fixtures play a crucial role in software testing as they provide a standardized and consistent test environment. They help in setting up the initial conditions required for executing test cases, ensuring that the tests are conducted under controlled circumstances. By using test fixtures, it becomes easier to reproduce test results and identify any issues or bugs in the software. They also help in maintaining the reliability and accuracy of test results.
3. How can test fixtures be implemented in software testing?
Ans. Test fixtures can be implemented in software testing by following a structured approach. This includes identifying the necessary setup, initialization, and configuration steps required for the test environment. These steps can be automated using test automation frameworks or written as manual instructions. It is important to ensure that the test fixtures are reusable, maintainable, and provide a clean state for each test case execution.
4. What are the common types of test fixtures used in software testing?
Ans. The common types of test fixtures used in software testing are: 1. Setup fixtures: These fixtures include the steps to set up the initial conditions required for executing test cases, such as creating test data, initializing variables, or configuring the system. 2. Teardown fixtures: These fixtures involve cleaning up or resetting the test environment after the execution of test cases. They ensure that the system is left in a consistent state for subsequent tests. 3. Test data fixtures: These fixtures provide the necessary data required for test case execution. They can include sample inputs, expected outputs, or predefined datasets. 4. Environment fixtures: These fixtures involve configuring the test environment, such as setting up network connections, database connections, or any other external dependencies.
5. What are the benefits of using test fixtures in software testing?
Ans. The benefits of using test fixtures in software testing are: 1. Consistency: Test fixtures help in ensuring that each test case is executed in a consistent and controlled environment, leading to reliable and repeatable test results. 2. Efficiency: By automating the setup and teardown steps, test fixtures save time and effort required for manual configuration, allowing testers to focus more on actual testing. 3. Reusability: Test fixtures can be reused across multiple test cases or test suites, promoting code reusability and reducing redundancy. 4. Maintainability: By separating the setup, teardown, and test data from the actual test case logic, test fixtures make it easier to maintain and update the test environment as the software evolves. 5. Debugging: Test fixtures provide a known starting point for testing, making it easier to identify and isolate issues or bugs in the software by comparing the expected and actual outcomes.
Download as PDF
Explore Courses for exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Download free EduRev App
Track your progress, build streaks, highlight & save important lessons and more!