Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
#244 module for junit (and custom listeners)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaihuludus committed Jul 1, 2018
1 parent 316f44a commit ec7ec4e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ protected void configure() {

Multibinder.newSetBinder(binder(),
RunListener.class);

}
}
10 changes: 10 additions & 0 deletions bb-junit/src/main/java/com/cognifide/qa/bb/junit/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@
*/
package com.cognifide.qa.bb.junit;

import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import com.google.inject.util.Types;
import java.util.List;
import java.util.Properties;

import java.util.Set;
import org.junit.Ignore;
import org.junit.internal.AssumptionViolatedException;
import org.junit.internal.runners.model.EachTestNotifier;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
Expand Down Expand Up @@ -72,6 +77,8 @@ public class TestRunner extends BlockJUnit4ClassRunner {

private final TestEventCollector testEventCollector;

private final Set<RunListener> customRunListeners;

/**
* Creates a Runner with Guice modules.
*
Expand All @@ -86,6 +93,8 @@ public TestRunner(final Class<?> classToRun)
injector = InjectorsMap.INSTANCE.forClass(classToRun);
properties = injector.getInstance(Properties.class);
testEventCollector = injector.getBinding(TestEventCollector.class).getProvider().get();
customRunListeners = injector.getInstance(Key.get((TypeLiteral<Set<RunListener>>)TypeLiteral.get(Types
.setOf(RunListener.class))));
reportingListener.addInjector(injector);
}

Expand Down Expand Up @@ -137,6 +146,7 @@ protected final void runChild(FrameworkMethod method, RunNotifier notifier) {
@Override
public void run(RunNotifier notifier) {
checkAndRegisterReportingListener(notifier);
customRunListeners.stream().forEach(notifier::addListener);
super.run(notifier);
}

Expand Down
19 changes: 19 additions & 0 deletions bb-reports-allure/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Bobcat
%%
Copyright (C) 2016 Cognifide Ltd.
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#L%
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand Down

0 comments on commit ec7ec4e

Please sign in to comment.