junit-drools

library for unit-testing drools rules

Лицензия

Лицензия

Категории

Категории

JUnit Тестирование компонентов
Группа

Группа

com.github.jeichler
Идентификатор

Идентификатор

junit-drools
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

junit-drools
library for unit-testing drools rules
Ссылка на сайт

Ссылка на сайт

http://github.com/jeichler/junit-drools
Система контроля версий

Система контроля версий

http://github.com/jeichler/junit-drools

Скачать junit-drools

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.jeichler/junit-drools/ -->
<dependency>
    <groupId>com.github.jeichler</groupId>
    <artifactId>junit-drools</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.jeichler/junit-drools/
implementation 'com.github.jeichler:junit-drools:1.0'
// https://jarcasting.com/artifacts/com.github.jeichler/junit-drools/
implementation ("com.github.jeichler:junit-drools:1.0")
'com.github.jeichler:junit-drools:jar:1.0'
<dependency org="com.github.jeichler" name="junit-drools" rev="1.0">
  <artifact name="junit-drools" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.jeichler', module='junit-drools', version='1.0')
)
libraryDependencies += "com.github.jeichler" % "junit-drools" % "1.0"
[com.github.jeichler/junit-drools "1.0"]

Зависимости

compile (5)

Идентификатор библиотеки Тип Версия
org.kie : kie-api jar
org.drools : drools-core jar
org.drools : drools-compiler jar
org.jbpm : jbpm-bpmn2 jar 6.2.0.Final
junit : junit jar 4.11

Модули Проекта

Данный проект не имеет модулей.

Build Status

Usage

The library is available on maven central. Simply include it in your pom:

<dependency>
	<groupId>com.github.jeichler</groupId>
	<artifactId>junit-drools</artifactId>
	<version>1.0</version>
	<scope>test</scope>
</dependency>

Then you can start right away unit-testing your rules:

@DroolsFiles(ruleFiles = {"some/folder/in/resources/YourRuleFile.drl", "some/folder/in/resources/YourRuleFlow.bpmn"})
@RunWith(DroolsJUnitRunner.class)
public class TestClass {

  //@StatelessDroolsSession
  @StatefulDroolsSession
  private DroolsSession session;
  
  //...
  
  @Test
  public void testMethod() {
    session.insert(yourObject);
    session.fireAllRules();
    Assert.assertTrue(session.getNumberOfFiredRules() == expectedNumberOfFiredRules);
  }

}

Some thoughts

Though I added support for rule flows (a pretty basic one, and yes, on purpose, i skipped adding whole folders at once because I'm not convinced that it helps testing your application.) I'm not a big fan of seeing them in unit tests). They should be part of integration tests and hence be run in the respective application context and the flows should be started by the respective components in your application. However for a quick peek you might use this runner for flows as well.

Версии библиотеки

Версия
1.0