我是否需要在我的代码中创建一个会话以在Jenkins中运行并行测试?

时间:2015-07-31 11:43:23

标签: jenkins thread-safety jbehave session-management parallel-testing

我即将在我的自动化项目上运行并行测试(我正在使用Jbehave),但我想知道我是否需要在我的代码中创建会话管理(线程管理),或者Jenkins是否可以为我执行此操作。谢谢!

2 个答案:

答案 0 :(得分:0)

使用以下插件来完成您的任务:

Build Flow Plugin

Multijob plugin

答案 1 :(得分:0)

您可以在构建流程作业的帮助下运行顺序和并行作业。

示例:

管道工作:

    parallel(
       build("job1")
       build("job2")
       ) 

平行工作:

+ (void)connectWithPOSTtoAPIURL:(NSString *)APIURLString
                     withParams:(NSDictionary *)params
                  withKeyObject:(NSString *)keyObject
                    andResponse:(void (^)(NSURLResponse *serviceResponse, id receivedData, NSError *error))responseHandler{


    NSError *jsonError;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:&jsonError];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", ParseRestAPIURL, APIURLString]];
    NSMutableURLRequest *dataRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
    [dataRequest setTimeoutInterval:30.0];
    [dataRequest setHTTPMethod:@"POST"];
    [dataRequest setValue:ParseApplicationID forHTTPHeaderField:@"X-Parse-Application-Id"];
    [dataRequest setValue:ParseRestAPIID forHTTPHeaderField:@"X-Parse-REST-API-Key"];
    [dataRequest setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[jsonData length]] forHTTPHeaderField:@"Content-Length"];
    [dataRequest setHTTPBody:jsonData];


    [NSURLConnection sendAsynchronousRequest:dataRequest
                                       queue:[NSOperationQueue mainQueue]
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

                               id receivedData;
                               if (connectionError) {
                               }

                               else {
                                   NSError *jsonError;
                                   receivedData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
                                   if (jsonError) {
                                   }else {
                                       // NSLog(@"OUTPUT DATA: %@", receivedData);
                                   }
                               }

                               responseHandler (response,receivedData,connectionError);
                           }];

}