TestDrive-Core

Pure Java implementation of spock testing framework

Лицензия

Лицензия

Группа

Группа

org.bytemechanics
Идентификатор

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

test-drive-core
Последняя версия

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

0.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

TestDrive-Core
Pure Java implementation of spock testing framework
Ссылка на сайт

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

https://test-drive.bytemechanics.org
Организация-разработчик

Организация-разработчик

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

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

https://github.com/bytemechanics/test-drive

Скачать test-drive-core

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

<!-- https://jarcasting.com/artifacts/org.bytemechanics/test-drive-core/ -->
<dependency>
    <groupId>org.bytemechanics</groupId>
    <artifactId>test-drive-core</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.bytemechanics/test-drive-core/
implementation 'org.bytemechanics:test-drive-core:0.2.0'
// https://jarcasting.com/artifacts/org.bytemechanics/test-drive-core/
implementation ("org.bytemechanics:test-drive-core:0.2.0")
'org.bytemechanics:test-drive-core:jar:0.2.0'
<dependency org="org.bytemechanics" name="test-drive-core" rev="0.2.0">
  <artifact name="test-drive-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.bytemechanics', module='test-drive-core', version='0.2.0')
)
libraryDependencies += "org.bytemechanics" % "test-drive-core" % "0.2.0"
[org.bytemechanics/test-drive-core "0.2.0"]

Зависимости

test (5)

Идентификатор библиотеки Тип Версия
org.spockframework : spock-core jar 1.2-groovy-2.4
org.codehaus.groovy : groovy jar 2.4.15
net.bytebuddy : byte-buddy jar 1.9.1
org.objenesis : objenesis jar 2.6
cglib : cglib jar 3.2.8

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

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

Copy Commons

Latest version Quality Gate Coverage License

Pure java testing framework implementation

Motivation

Spock framework is fantastic but use groovy to test java always will be become a mess. After executing a test that should fail and does not fail. Decided that this must be done in pure java.

Quick start

(Please read our Javadoc for further information)

  1. First of all include the Jar file in your compile and execution classpath.

    Maven

    <dependency>
        <groupId>org.bytemechanics</groupId>
        <artifactId>test-drive</artifactId>
        <version>X.X.X</version>
        <type>test</type>
    </dependency>
  2. In your maven pom.xml activate the surefire test-drive provider by adding the corresponding dependency

     <build>
     	<plugins>
     		<plugin>
     			<groupId>org.apache.maven.plugins</groupId>
     			<artifactId>maven-surefire-plugin</artifactId>
     			<version>X.XX.X</version>
     			(...)
     			<dependencies>
     				<dependency>
     					<groupId>org.bytemechanics</groupId>
     					<artifactId>testdrive-surefire</artifactId>
     					<version>X.X.X</version>
     				</dependency>
     			</dependencies>
     		</plugin>
     	</plugins>
     </build>
  3. In your maven pom.xml activate the suffix you will use (tipically Spec)

     <build>
     	<plugins>
     		<plugin>
     			<groupId>org.apache.maven.plugins</groupId>
     			<artifactId>maven-surefire-plugin</artifactId>
     			<version>X.XX.X</version>
     			<configuration>
     				<includes>
     					<include>*Spec.java</include>
     					(...)
     				</includes>
     			</configuration>
     			(...)
     		</plugin>
     	</plugins>
     </build>
  4. Create your first spec

    • Option 1: non-driven

      import org.bytemechanics.testdrive.Specification;
      import org.bytemechanics.testdrive.annotations.Evaluation;
      import org.bytemechanics.testdrive.annotations.Test;
      import org.bytemechanics.testdrive.Assert;
      
      public class AddIntegerSpec implements Specification {
      
         (...)
      
      	@Test(name="accumulate {} and {} should result with {} with driven test", evaluations = {
      		@Evaluation(name = "one",args = {"1","1","0","2"}),
      		@Evaluation(name = "zero",args = {"0","0","0","0"})
      	})
      	public void accumulate(final int _base,final int _val1,final int _val2,final int _expected){
      
         	int base=_base;
         	int actual=base+_val1+_val2;
         	Assert.assertEquals(actual,_expected);
      	}
         (...)
      }
    • Option 2: non-driven with labels

      import org.bytemechanics.testdrive.Specification;
      import org.bytemechanics.testdrive.annotations.Evaluation;
      import org.bytemechanics.testdrive.annotations.Test;
      import org.bytemechanics.testdrive.Assert;
      
      public class AddIntegerSpec implements Specification {
      
         (...)
      
      	@Test(name="accumulate {} and {} should result with {} with driven test", evaluations = {
      		@Evaluation(name = "one",args = {"1","1","0","2"}),
      		@Evaluation(name = "zero",args = {"0","0","0","0"})
      	})
      	public void accumulate(final int _base,final int _val1,final int _val2,final int _expected){
      
         	int base,actual;
      
         	given:
         		base=_base;
         	when:
         		actual=base+_val1+_val2;
         	then:
         		Assert.assertEquals(actual,_expected);
      	}
         (...)
      }
    • Option 3: driven

      import org.bytemechanics.testdrive.DrivenTest;
      import org.bytemechanics.testdrive.Specification;
      import org.bytemechanics.testdrive.annotations.Evaluation;
      import org.bytemechanics.testdrive.annotations.Test;
      import org.bytemechanics.testdrive.example.AddInteger;
      import org.bytemechanics.testdrive.exceptions.AssertException;
      import org.bytemechanics.testdrive.Assert;
      
      public class AddIntegerSpec implements Specification {
      
         (...)
      
      	@Test(name="accumulate {} and {} should result with {} with driven test", evaluations = {
      		@Evaluation(name = "one",args = {"1","1","0","2"}),
      		@Evaluation(name = "zero",args = {"0","0","0","0"})
      	})
         public DrivenTest accumulateDriven(final int _base,final int _val1,final int _val2,final int _expected){
         	return new DrivenTest() {
      
         		int base,actual;
      
         		@Override
         		public void given() {
         			this.base=_base;
         		}
         		@Override
         		public void when() {
         			this.actual=this.base+_val1+_val2;
         		}
         		@Override
         		public void then() throws AssertException {
         			Assert.assertEquals(this.actual,_expected);
         		}
         	};
         }
         (...)
      }

For additional information please refer example project

org.bytemechanics

ByteMechanics Foundation

Foundation dedicated to provide opensource libraries and resources to simplify developers life

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

Версия
0.2.0