# How to choose a testcase class from command line on SV

**URL:** <https://verificationacademy.com/forums/t/how-to-choose-a-testcase-class-from-command-line-on-sv/31887>\
**Category:** SystemVerilog\
**Tags:** Command-Line-Processing, SystemVerilog, Polymorphism, testcase, valueplusargs\
**Created:** [June 2, 2016, 11:58am UTC](https://verificationacademy.com/forums/t/how-to-choose-a-testcase-class-from-command-line-on-sv/31887 "2016-06-02T11:58:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [June 2, 2016, 3:09pm UTC](https://verificationacademy.com/forums/t/how-to-choose-a-testcase-class-from-command-line-on-sv/31887/2 "2016-06-02T15:09:19Z")

</div>

_In reply to [vadivelan014](https://verificationacademy.com/forums/t/how-to-choose-a-testcase-class-from-command-line-on-sv/31887):_

You can do it brute force with a case statement

```verilog
case (test_name)
"test_base" : test = new();
"test1" : test = test1::new();
"test2" : test = test2::new();
endcase

```

Or you can build your own factory can look-up the class by a string name in an associative array. If you want to understand how the factory works, check out my new [SystemVerilog OOP course](https://verificationacademy.com/courses/systemverilog-oop-for-uvm-verification), especially the third session.

---

_[View the full topic](https://verificationacademy.com/forums/t/how-to-choose-a-testcase-class-from-command-line-on-sv/31887)._
