Wednesday, February 15, 2012 8:59 PM
Is it possible to add deploymentitem attribute to the webtest programatically to RecordedWebTest object instead of visual studio interface?
Wednesday, February 15, 2012 10:49 PM
Hi Performance Engineer,
I think it would be better to let us know what your trying to solve by doing this, and we might be able to help come up with a solution. It looks like you might be trying to get a file deployed as part of the test, but you want something about that to be dynamic? Anway let us know the scenario your envisioning and we can take it from there.
Attributes are processed by the compiler at compile time, so you would have to modify the actual source code before compiling anyway. If there is a way to change this after compilation it would be through Reflection, but I do not know if thats even possible, although it is possible to create your own Custom Attributes.
Thursday, February 16, 2012 12:54 AM
The easiest thing to do would be to generate a coded web test. You can then add the deploymentItem attribute to the coded web test.
If you dont want to generate code, you can add a unit test to the same project. Then add this code in the unit test cs file:
public static void AssemblyInit(TestContext context)
MessageBox.Show("AssemblyInit " + context.TestName);
Hope this helps.
Thursday, February 16, 2012 12:20 PM
Thanks for your reply.
What I have writen is webtest automation tool which parameterize the variables, add data source and lots of other things through program to the webtest so I dont need to touch webtest before running the test. Now I have one CSV datasource which I have added to the webtest using code and I wanted to make sure this csv file gets marked as deployment item in the webtest so that it gets copied along with webtest dlls on the test controller box when the test runs.
When I add datasource through interface it asks me to make this item as deployable or not and when I say yes it adds DeploymentItem attribute to the webtest automatically and I wanted to replicate the same behaviour through code to avoid manual step of adding deployment item to the webtest.
Thursday, February 16, 2012 4:35 PM
I think I have found the solution. I added the file in the testsettings's Deployment settings and now it adds that attribute to every WebTest automatically.
- Marked As Answer by Performance Engineer Thursday, February 16, 2012 4:36 PM