Forum Discussion
SmartBear_Suppo
Alumni
15 years agoHello,
The Project Setup Script will be run once, when the project is loaded. This will never be during part of a LoadTest, and thus will never have a LoadTestContext. If you want to run something at the start of a LoadTest, you would generally put it in the LoadTest Setup Script, but that will only work in soapUI, not in loadUI. If you need initialization for the LoadTestContext which works for both soapUI and loadUI you can use the Groovy TestStep. This will run once in each run of the TestCase, so you will need to add some code so that initialization is only done once, for example:
Basically, the LoadTestContext lives for the duration of a soapUI LoadTest. In loadUI it lives for the lifetime of the Project, so to reset it you currently need to close the project and re-open it. This is an oversight and will be fixed so that the LoadTestContext is reset when the test ends. Hopefully we'll have it fixed pretty soon.
UPDATE: I've fixed this now so that the LoadTestContext in loadUI is reset as you would expect. The fix will be in the upcoming nightly build of loadUI here as well as in the next upcoming release of loadUI. The LoadTestContext should now reset on start of the test, and when manually pressing the "Reset" button.
Regards,
Dain
eviware.com
The Project Setup Script will be run once, when the project is loaded. This will never be during part of a LoadTest, and thus will never have a LoadTestContext. If you want to run something at the start of a LoadTest, you would generally put it in the LoadTest Setup Script, but that will only work in soapUI, not in loadUI. If you need initialization for the LoadTestContext which works for both soapUI and loadUI you can use the Groovy TestStep. This will run once in each run of the TestCase, so you will need to add some code so that initialization is only done once, for example:
//Groovy Test Step:
if( context.LoadTestContext ) {
synchronized( context.LoadTestContext ) {
//Initialize only if not already initialized
if( !context.LoadTestContext['init'] ) {
context.LoadTestContext['init'] = true
context.LoadTestContext['UserPrefix'] = "Some value"
//Add the rest of the initialization here...
}
//And use/modify the context:
def user_prefix = context.LoadTestContext['UserPrefix']
// ... and so on
}
}
Basically, the LoadTestContext lives for the duration of a soapUI LoadTest. In loadUI it lives for the lifetime of the Project, so to reset it you currently need to close the project and re-open it. This is an oversight and will be fixed so that the LoadTestContext is reset when the test ends. Hopefully we'll have it fixed pretty soon.
UPDATE: I've fixed this now so that the LoadTestContext in loadUI is reset as you would expect. The fix will be in the upcoming nightly build of loadUI here as well as in the next upcoming release of loadUI. The LoadTestContext should now reset on start of the test, and when manually pressing the "Reset" button.
Regards,
Dain
eviware.com