Ejemplo n.º 1
0
func (exe *simpleExecution) executeStream(specs *specList) *result.SuiteResult {
	startTime := time.Now()
	exe.suiteResult = result.NewSuiteResult()
	exe.suiteResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	exe.suiteResult.ProjectName = filepath.Base(config.ProjectRoot)
	exe.suiteResult.Environment = env.CurrentEnv
	exe.suiteResult.Tags = ExecuteTags
	initSuiteDataStoreResult := exe.initializeSuiteDataStore()
	if initSuiteDataStoreResult.GetFailed() {
		exe.logger.Error("Failed to initialize suite datastore. Error: %s", initSuiteDataStoreResult.GetErrorMessage())
	} else {
		beforeSuiteHookExecResult := exe.startExecution()
		if beforeSuiteHookExecResult.GetFailed() {
			result.AddPreHook(exe.suiteResult, beforeSuiteHookExecResult)
			exe.suiteResult.SetFailure()
		} else {
			for !specs.isEmpty() {
				exe.executeSpec(specs.getSpec())
			}
		}
		afterSuiteHookExecResult := exe.endExecution()
		if afterSuiteHookExecResult.GetFailed() {
			result.AddPostHook(exe.suiteResult, afterSuiteHookExecResult)
			exe.suiteResult.SetFailure()
		}
	}
	exe.suiteResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return exe.suiteResult
}
Ejemplo n.º 2
0
func (exe *simpleExecution) start() *result.SuiteResult {
	startTime := time.Now()
	exe.suiteResult = result.NewSuiteResult()
	exe.suiteResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	exe.suiteResult.ProjectName = filepath.Base(config.ProjectRoot)
	exe.suiteResult.Environment = env.CurrentEnv
	exe.suiteResult.Tags = ExecuteTags
	exe.suiteResult.SpecsSkippedCount = len(exe.errMaps.specErrs)
	initSuiteDataStoreResult := exe.initializeSuiteDataStore()
	if initSuiteDataStoreResult.GetFailed() {
		exe.logger.Error("Failed to initialize suite datastore. Error: %s", initSuiteDataStoreResult.GetErrorMessage())
	} else {
		beforeSuiteHookExecResult := exe.startExecution()
		if beforeSuiteHookExecResult.GetFailed() {
			result.AddPreHook(exe.suiteResult, beforeSuiteHookExecResult)
			exe.suiteResult.SetFailure()
			printStatus(beforeSuiteHookExecResult, exe.logger)
		} else {
			for _, specificationToExecute := range exe.specifications {
				exe.executeSpec(specificationToExecute)
			}
		}
		afterSuiteHookExecResult := exe.endExecution()
		if afterSuiteHookExecResult.GetFailed() {
			result.AddPostHook(exe.suiteResult, afterSuiteHookExecResult)
			exe.suiteResult.SetFailure()
			printStatus(afterSuiteHookExecResult, exe.logger)
		}
	}
	exe.suiteResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return exe.suiteResult
}
Ejemplo n.º 3
0
func (exe *simpleExecution) start() *result.SuiteResult {
	startTime := time.Now()
	exe.suiteResult = result.NewSuiteResult()
	exe.suiteResult.Timestamp = startTime.Format(config.LayoutForTimeStamp)
	exe.suiteResult.ProjectName = filepath.Base(config.ProjectRoot)
	exe.suiteResult.Environment = env.CurrentEnv
	exe.suiteResult.Tags = ExecuteTags
	beforeSuiteHookExecResult := exe.startExecution()
	if beforeSuiteHookExecResult.GetFailed() {
		result.AddPreHook(exe.suiteResult, beforeSuiteHookExecResult)
		exe.suiteResult.SetFailure()
	} else {
		for _, specificationToExecute := range exe.specifications {
			executor := newSpecExecutor(specificationToExecute, exe.runner, exe.pluginHandler, getDataTableRows(specificationToExecute.DataTable.Table.GetRowCount()), exe.logger)
			protoSpecResult := executor.execute()
			exe.suiteResult.AddSpecResult(protoSpecResult)
		}
	}
	afterSuiteHookExecResult := exe.endExecution()
	if afterSuiteHookExecResult.GetFailed() {
		result.AddPostHook(exe.suiteResult, afterSuiteHookExecResult)
		exe.suiteResult.SetFailure()
	}
	exe.suiteResult.ExecutionTime = int64(time.Since(startTime) / 1e6)
	return exe.suiteResult
}
Ejemplo n.º 4
0
func (e *parallelExecution) aggregateResults(suiteResults []*result.SuiteResult) {
	r := result.NewSuiteResult(ExecuteTags, e.startTime)
	r.SpecsSkippedCount = len(e.errMaps.SpecErrs)
	for _, result := range suiteResults {
		r.SpecsFailedCount += result.SpecsFailedCount
		r.SpecResults = append(r.SpecResults, result.SpecResults...)
		if result.IsFailed {
			r.IsFailed = true
		}
		if result.PreSuite != nil {
			r.PreSuite = result.PreSuite
		}
		if result.PostSuite != nil {
			r.PostSuite = result.PostSuite
		}
		if result.UnhandledErrors != nil {
			r.UnhandledErrors = append(r.UnhandledErrors, result.UnhandledErrors...)
		}
	}
	r.ExecutionTime = int64(time.Since(e.startTime) / 1e6)
	e.suiteResult = r
}
Ejemplo n.º 5
0
func (e *simpleExecution) execute() {
	e.suiteResult = result.NewSuiteResult(ExecuteTags, e.startTime)
	setResult := func() {
		e.suiteResult.ExecutionTime = int64(time.Since(e.startTime) / 1e6)
		e.suiteResult.SpecsSkippedCount = len(e.errMaps.SpecErrs)
	}

	initSuiteDataStoreResult := e.initSuiteDataStore()
	if initSuiteDataStoreResult.GetFailed() {
		e.consoleReporter.Errorf("Failed to initialize suite datastore. Error: %s", initSuiteDataStoreResult.GetErrorMessage())
		setResult()
		return
	}

	e.notifyBeforeSuite()
	if !e.suiteResult.IsFailed {
		e.executeSpecs(e.specCollection)
	}
	e.notifyAfterSuite()

	setResult()
}
Ejemplo n.º 6
0
func (e *simpleExecution) run() *result.SuiteResult {
	e.suiteResult = result.NewSuiteResult(ExecuteTags, e.startTime)
	initSuiteDataStoreResult := e.initializeSuiteDataStore()
	if initSuiteDataStoreResult.GetFailed() {
		e.consoleReporter.Error("Failed to initialize suite datastore. Error: %s", initSuiteDataStoreResult.GetErrorMessage())
	} else {
		beforeSuiteHookExecResult := e.startExecution()
		if beforeSuiteHookExecResult.GetFailed() {
			handleHookFailure(e.suiteResult, beforeSuiteHookExecResult, result.AddPreHook, e.consoleReporter)
		} else {
			for e.specStore.hasNext() {
				e.executeSpec(e.specStore.next())
			}
		}
		afterSuiteHookExecResult := e.endExecution()
		if afterSuiteHookExecResult.GetFailed() {
			handleHookFailure(e.suiteResult, afterSuiteHookExecResult, result.AddPostHook, e.consoleReporter)
		}
	}
	e.suiteResult.ExecutionTime = int64(time.Since(e.startTime) / 1e6)
	e.suiteResult.SpecsSkippedCount = len(e.errMaps.specErrs)
	return e.suiteResult
}