otasco

Initializes the class under test with it dependencies so that you do not have to declare setters just for testing.

License

License

GroupId

GroupId

com.box20six
ArtifactId

ArtifactId

otasco
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

otasco
Initializes the class under test with it dependencies so that you do not have to declare setters just for testing.
Source Code Management

Source Code Management

https://github.com/kenyattaclark/otasco

Download otasco

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
commons-beanutils : commons-beanutils jar 1.8.3
org.functionaljava : functionaljava jar 3.0
org.apache.commons : commons-lang3 jar 3.1

provided (2)

Group / Artifact Type Version
junit : junit jar 4.10
org.mockito : mockito-all jar 1.9.0

Project Modules

There are no modules declared in this project.
  • Allows testing class under test without creating useless setters for dependencies.

  • Makes the test class more readable.

      public class InvoiceManagerTest { 
          @ClassUnderTest private InvoiceManager manager;
          
          @Dependency private InvoiceCalculator invoiceCalculator;
         
          @Dependency private InvoiceDao invoiceDao;
          
          @Before public void setup() {
              invoiceCalculator = new InvoiceCalculator();
              invoiceDao = new InvoiceDao();
              manager = new InvoiceManager();
              Otasco.init(this);
          }
      }
    

  • Possibly using Mockito (or your favorite mocking library)

      @RunWith(OtascoMockitoJUnitRunner.class)
      public class InvoiceManagerTest {
          @ClassUnderTest private InvoiceManager manager;
                      
          @Dependency
          @Mock
          private InvoiceCalculator invoiceCalculator;
                      
          @Dependency
          @Mock
          private InvoiceDao invoiceDao;
                      
      }
    

Versions

Version
1.0.0