Use Win Form in a VS Team Test library

 

This may be common knowledge, but I just discovered it. Test projects in VS Team Test are class libraries. Normally you write tests like a console app, with no UI. You just test api results and test results with the Assert class – nice, simple and works great. However, a lot of times, I like testing and modeling work in progress with a UI form. I just add a bunch of buttons each with some code I am testing. Works good for me as it is visually organized and double-click to see code-behind is just so natural. I use a form as a kind of scratch pad for ideas and small tests on logic. Not as a replacement for unit tests, but as dev tool. Also a nice way to create various samples for using your library. Nuf said. Anyway, I thought it would be nice to pop a form up as one of the unit tests and work with it. Kinda like a manual test. This is nice because you don’t need to create yet another Project just to create Windows Form test harness and junk up your dir structure. So to keep your forms and helper class in the Test project library. Here is sort summary:

  1. Create a Windows form in the project as normal. This will add the System.Windows.Forms reference for you.
  2. Open your blank form and add buttons and logic as needed.
  3. Add a new "Unit Test" to the project and pick a good name.
  4. Add a [TestMethod] method to the class and call it something like TestForm1. This is the unit test method that will be called via testing framework. Add code to open your form in this method; something like:

    [TestMethod]


public
void TestMethod1()

{


Application.EnableVisualStyles();


Application.SetCompatibleTextRenderingDefault(false);


Application.Run(new
Form1());

 


////Microsoft.VisualStudio.TestTools.UnitTesting


//Form1 f1 = new Form1();


//f1.ShowDialog();

}

    You can either use the Application.Run method or just use ShowDialog() as shown.

  1. Run your "TestForm1" unit test. It will bring up your form. You can click and test your form as needed. All Console.WriteLine() output will be collected into the Test Result for the unit test. You will see it only after you close the form. Any uncaught exception will also be posted in the test output record. This makes it nice and tidy.
  2. When you close your form, your other selected tests (if any) will continue. Perfect!

Add as many forms or classes as you need. Using this method, you can collect all your samples into the same test project and distro a single library along with your other project you are testing.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Use Win Form in a VS Team Test library

  1. Unknown says:

    http://www.batteryfast.com/asus/f3.htm Asus f3 Battery http://www.batteryfast.com/toshiba/pa3594u-1brs.htm Toshiba pa3594u-1brs Battery http://www.batteryfast.com/toshiba/pa3593u-1bas.htm Toshiba pa3593u-1bas Battery http://www.batteryfast.com/toshiba/pabas111.htm Toshiba pabas111 Battery http://www.batteryfast.com/dell/xps-m1530.htm Dell xps m1530 Battery http://www.batteryfast.com/hp/tx2000.htm Hp tx2000 Battery http://www.batteryfast.com/hp/pavilion-tx1000.htm Hp pavilion tx1000 Battery http://www.batteryfast.com/dell/xps-m1730.htm Dell xps m1730 Battery http://www.batteryfast.com/hp/pavilion-dv6.htm Hp pavilion dv6 Battery http://www.batteryfast.com/toshiba/pa3395u-1brs.htm Toshiba pa3395u-1brs Battery http://www.batteryfast.com/toshiba/pa3421u-1brs.htm Toshiba pa3421u-1brs Battery http://www.batteryfast.com/toshiba/pa3451u-1brs.htm Toshiba pa3451u-1brs Battery http://www.batteryfast.com/toshiba/pa3399u-1brs.htm Toshiba pa3399u-1brs Battery http://www.batteryfast.com/toshiba/pa3399u-2bas.htm Toshiba pa3399u-2bas Battery http://www.batteryfast.com/toshiba/satellite-a100.htm Toshiba satellite a100 Battery http://www.batteryfast.com/toshiba/satellite-m40.htm Toshiba satellite m40 Battery http://www.batteryfast.com/toshiba/satellite-m45.htm Toshiba satellite m45 Battery http://www.batteryfast.com/toshiba/satellite-m55.htm Toshiba satellite m55 Battery http://www.batteryfast.com/toshiba/pa3356u.htm Toshiba pa3356u Battery http://www.batteryfast.com/toshiba/pa3356u-1bas.htm Toshiba pa3356u-1bas Battery http://www.batteryfast.com/toshiba/pa3356u-1brs.htm Toshiba pa3356u-1brs Battery http://www.batteryfast.com/toshiba/pa3356u-2brs.htm Toshiba pa3356u-2brs Battery http://www.batteryfast.com/toshiba/pa3456u-1brs.htm Toshiba pa3456u-1brs Battery http://www.batteryfast.com/toshiba/portege-m500.htm Toshiba portege m500 Battery http://www.batteryfast.com/toshiba/pa3451u.htm Toshiba pa3451u Battery http://www.batteryfast.com/toshiba/pabas067.htm Toshiba pabas067 Battery http://www.batteryfast.com/toshiba/pa3465u-1brs.htm Toshiba pa3465u-1brs Battery http://www.batteryfast.com/toshiba/pa3534u-1brs.htm Toshiba pa3534u-1brs Battery http://www.batteryfast.com/toshiba/pa3533u-1bas.htm Toshiba pa3533u-1bas Battery http://www.batteryfast.com/toshiba/satellite-a205.htm Toshiba satellite a205 Battery http://www.batteryfast.com/toshiba/pa3534u-1bas.htm Toshiba pa3534u-1bas Battery http://www.batteryfast.com/uniwill/255-3s4400-g1l1.htm Uniwill 255-3s4400-g1l1 Battery http://www.batteryfast.com/uniwill/un255.htm Uniwill un255 Battery

  2. Unknown says:

    http://www.batterylaptoppower.com/toshiba/4000.htm toshiba 4000 battery http://www.batterylaptoppower.com/toshiba/pa3062u-1bar.htm toshiba pa3062u-1bar battery http://www.batterylaptoppower.com/toshiba/tecra-8200.htm toshiba tecra 8200 battery http://www.batterylaptoppower.com/toshiba/pa3128u.htm toshiba pa3128u battery http://www.batterylaptoppower.com/toshiba/pa3191u.htm toshiba pa3191u battery http://www.batterylaptoppower.com/toshiba/portege-4000.htm toshiba portege 4000 battery http://www.batterylaptoppower.com/toshiba/portege-m200.htm toshiba portege m200 battery http://www.batterylaptoppower.com/toshiba/portege-m205.htm toshiba portege m205 battery http://www.batterylaptoppower.com/toshiba/portege-m400.htm toshiba portege m400 battery http://www.batterylaptoppower.com/toshiba/pa3128u-grey.htm toshiba pa3128u grey battery http://www.batterylaptoppower.com/toshiba/pa3191u-grey.htm toshiba pa3191u grey battery http://www.batterylaptoppower.com/toshiba/te2000-grey.htm toshiba te2000 grey battery http://www.batterylaptoppower.com/toshiba/pa3209u.htm toshiba pa3209u battery http://www.batterylaptoppower.com/toshiba/satellite-1100.htm toshiba satellite 1100 battery http://www.batterylaptoppower.com/toshiba/satellite-1110.htm toshiba satellite 1110 battery http://www.batterylaptoppower.com/toshiba/pa3210u.htm toshiba pa3210u battery http://www.batterylaptoppower.com/toshiba/satellite-1115.htm toshiba satellite 1115 battery http://www.batterylaptoppower.com/toshiba/pa3399u-1bas.htm toshiba pa3399u-1bas battery http://www.batterylaptoppower.com/toshiba/satellite-a100.htm toshiba satellite a100 battery http://www.batterylaptoppower.com/toshiba/satellite-m100.htm toshiba satellite m100 battery http://www.batterylaptoppower.com/toshiba/pa3399u-1bas.htm toshiba pa3399u-1bas battery http://www.batterylaptoppower.com/toshiba/satellite-a100.htm toshiba satellite a100 battery http://www.batterylaptoppower.com/toshiba/satellite-a105.htm toshiba satellite a105 battery http://www.batterylaptoppower.com/toshiba/satellite-a80.htm toshiba satellite a80 battery http://www.batterylaptoppower.com/toshiba/satellite-m100.htm toshiba satellite m100 battery http://www.batterylaptoppower.com/toshiba/satellite-m105.htm toshiba satellite m105 battery http://www.batterylaptoppower.com/toshiba/satellite-m110.htm toshiba satellite m110 battery http://www.batterylaptoppower.com/toshiba/satellite-m115.htm toshiba satellite m115 battery http://www.batterylaptoppower.com/toshiba/satellite-m40.htm toshiba satellite m40 battery http://www.batterylaptoppower.com/toshiba/satellite-m45.htm toshiba satellite m45 battery http://www.batterylaptoppower.com/toshiba/satellite-m50.htm toshiba satellite m50 battery http://www.batterylaptoppower.com/toshiba/satellite-m55.htm toshiba satellite m55 battery http://www.batterylaptoppower.com/toshiba/pa3356u.htm toshiba pa3356u battery http://www.batterylaptoppower.com/toshiba/a50.htm toshiba a50 battery http://www.batterylaptoppower.com/toshiba/a55.htm toshiba a55 battery http://www.batterylaptoppower.com/toshiba/portege-m300.htm toshiba portege m300 battery http://www.batterylaptoppower.com/toshiba/portege-m500.htm toshiba portege m500 battery http://www.batterylaptoppower.com/toshiba/portege-s100.htm toshiba portege s100 battery http://www.batterylaptoppower.com/toshiba/qosmio-f20.htm toshiba qosmio f20 battery http://www.batterylaptoppower.com/toshiba/qosmio-f25.htm toshiba qosmio f25 battery http://www.batterylaptoppower.com/toshiba/satellite-a50.htm toshiba satellite a50 battery http://www.batterylaptoppower.com/toshiba/satellite-a55.htm toshiba satellite a55 battery http://www.batterylaptoppower.com/toshiba/pa3356u-1bas.htm toshiba pa3356u-1bas battery http://www.batterylaptoppower.com/toshiba/satellite-a50.htm toshiba satellite a50 battery http://www.batterylaptoppower.com/toshiba/satellite-a55.htm toshiba satellite a55 battery

  3. Unknown says:

    http://www.adapterlist.com/dell/latitude-d531.htm dell latitude d531 battery http://www.adapterlist.com/dell/precision-m65.htm dell precision m65 battery http://www.adapterlist.com/dell/d820.htm dell d820 battery http://www.adapterlist.com/dell/inspiron-6000.htm dell inspiron 6000 battery http://www.adapterlist.com/dell/inspiron-9200.htm dell inspiron 9200 battery http://www.adapterlist.com/dell/inspiron-9300.htm dell inspiron 9300 battery http://www.adapterlist.com/dell/inspiron-9400.htm dell inspiron 9400 battery http://www.adapterlist.com/dell/e1705.htm dell e1705 battery http://www.adapterlist.com/dell/inspiron-1520.htm dell inspiron 1520 battery http://www.adapterlist.com/dell/inspiron-1720.htm dell inspiron 1720 battery http://www.adapterlist.com/dell/vostro-1500.htm dell vostro 1500 battery http://www.adapterlist.com/dell/vostro-1700.htm dell vostro 1700 battery http://www.adapterlist.com/dell/0xr693.htm dell 0xr693 battery http://www.adapterlist.com/dell/312-0625.htm dell 312-0625 battery http://www.adapterlist.com/dell/312-0633.htm dell 312-0633 battery http://www.adapterlist.com/dell/gw240.htm dell gw240 battery http://www.adapterlist.com/dell/hp297.htm dell hp297 battery http://www.adapterlist.com/dell/rn873.htm dell rn873 battery http://www.adapterlist.com/dell/xr693.htm dell xr693 battery http://www.adapterlist.com/dell/inspiron-1525.htm dell inspiron 1525 battery http://www.adapterlist.com/dell/inspiron-1526.htm dell inspiron 1526 battery http://www.adapterlist.com/dell/m1210.htm dell m1210 battery http://www.adapterlist.com/dell/nf343.htm dell nf343 battery http://www.adapterlist.com/dell/1210.htm dell 1210 battery http://www.adapterlist.com/dell/cg036.htm dell cg036 battery http://www.adapterlist.com/dell/d044h.htm dell d044h battery http://www.adapterlist.com/dell/w953g.htm dell w953g battery http://www.adapterlist.com/dell/312-0831.htm dell 312-0831 battery http://www.adapterlist.com/dell/inspiron-910.htm dell inspiron 910 battery http://www.adapterlist.com/dell/inspiron-mini-9.htm dell inspiron mini 9 battery http://www.adapterlist.com/dell/xd187.htm dell xd187 battery http://www.adapterlist.com/dell/inspiron-1300.htm dell inspiron 1300 battery http://www.adapterlist.com/dell/inspiron-b120.htm dell inspiron b120 battery http://www.adapterlist.com/dell/inspiron-b130.htm dell inspiron b130 battery http://www.adapterlist.com/gateway/12msbg.htm gateway 12msbg battery http://www.adapterlist.com/gateway/4s2p.htm gateway 4s2p battery http://www.adapterlist.com/gateway/8msb.htm gateway 8msb battery http://www.adapterlist.com/gateway/8msbg.htm gateway 8msbg battery http://www.adapterlist.com/gateway/s62044l.htm gateway s62044l battery http://www.adapterlist.com/gateway/m320.htm gateway m320 battery http://www.adapterlist.com/gateway/m325.htm gateway m325 battery http://www.adapterlist.com/gateway/4000.htm gateway 4000 battery http://www.adapterlist.com/gateway/s62066l.htm gateway s62066l battery http://www.adapterlist.com/gateway/m680.htm gateway m680 battery http://www.adapterlist.com/gateway/m360.htm gateway m360 battery http://www.adapterlist.com/gateway/m460.htm gateway m460 battery http://www.adapterlist.com/gateway/s62066l.htm gateway s62066l battery http://www.adapterlist.com/gateway/bat0016.htm gateway bat0016 battery http://www.adapterlist.com/gateway/m1200.htm gateway m1200 battery http://www.adapterlist.com/gateway/m1300.htm gateway m1300 battery http://www.adapterlist.com/gateway/m500.htm gateway m500 battery http://www.adapterlist.com/gateway/m505.htm gateway m505 battery http://www.adapterlist.com/gateway/btp-68b3.htm gateway btp-68b3 battery http://www.adapterlist.com/gateway/btp-51b3.htm gateway btp-51b3 battery http://www.adapterlist.com/hp/hstnn-db11.htm hp hstnn-db11 battery

Comments are closed.