Git Product home page Git Product logo

atunit's People

Watchers

 avatar

atunit's Issues

Remove JUnit Coupling

Hi,

It would be could to support all testing frameworks (like testng). A
drawback to this is that you can only rely on test instances created by the
framework, and thus you cannot, like juhttp://code.google.com/p/atunit/nit,
provide your proper test instance given a class (i.e. proxy the test class
to be executed).

I am currently finishing an integration testing framework
(http://code.mycila.com/). Supporting through plugins jmock, easymock,
mockito, guice, spring, ... and also AtUnit.

So i had to take some classes and refactor them a little (AtUnit.java,
mockers and containers) to remove junit imports.

So perhaps it would be nice 
- to have a new Container interface that works on the test instance
- to have a test instance enhancer decoupled from junit that embed all the
non junit code from AtUnit.java
- to use non junit code in Jmock plugin

You can have a look of teh classes here:
http://code.google.com/p/mycila/source/browse/#svn/mycila-testing/trunk/mycila-t
esting-plugins/mycila-testing-atunit/src/main/java/com/mycila/testing/plugin/atu
nit

Cheers,

Mathieu.

Original issue reported on code.google.com by [email protected] on 5 Dec 2008 at 3:33

GuiceContainer: bind mocks and stubs with annotations if present (esp. @Named)

GuiceContainer binds field types to values, but does not take annotations
into account.  If a field has non-atunit annotations, they should be used
at binding.

Example:

{{{
@Mock @Named("mymanager") Manager;
}}}

is currently bound like so:

{{{
binder.bind(Manager.class).toInstance(mock);
}}}

but should be bound with something equivalent to:

{{{
binder.bind(Manager.class).annotatedWith(Names.named("mymanager")).toInstance(mo
ck);
}}}

Original issue reported on code.google.com by [email protected] on 19 Nov 2007 at 3:35

EasyMock auto replay/verify?

(Not a defect).

I really like how the @Mocks are automagically created but it really pains
me to have to replay and verify them for each test.

I have written the attached helper class to replay and verify all @Mock and
@Stub test members.  (Note I'm using easymock classextensions).

Do you have any thoughts on how replay/verify functionality could be
integrated into atunit?

Original issue reported on code.google.com by [email protected] on 23 Nov 2007 at 1:02

Attachments:

AtUnit doesn't work with Guice and JMock (tests that should fail pass)

The below test should fail, but no matter what expectation i set, it 
passes.

@RunWith(AtUnit.class)
@Container(Container.Option.GUICE)
@MockFramework(MockFramework.Option.JMOCK)
public class myTest extends MyModule{

  @Inject @Unit TestInterface testInterface;

  Mockery mockery;
  @Mock TestObject obj;

  @Test
  public void shouldFailTest() {

    context.checking(new Expectations() {{
      oneOf (obj).doTest();
    }});

    testInterface.testMethod(obj);
  }
}

public interface TestInterface {
  public void testMethod(TestObject obj);
}

public interface TestObject {
  public void doTest()
}

@Singleton
public class TestInterfaceImpl implements TestInterface {

  public void testMethod(TestObject obj){
    // no call to doTest() here!
  }
}

@Singleton
public class TestObjectImpl implements TestObject {

  public void doTest(){
    // random crap just in case
    int i = 0;
    i++;
  }
}

public class MyModule extends ServletModule {

  @Override
  protected void configureServlets() {
    bind(TestInterface.class).to(TestInterfaceImpl.class);
  }
}

The test described here should fail. I cannot get it to fail for the life 
of me. I hope it's something in my configuration, but I can't see it.

-Tristan

Original issue reported on code.google.com by [email protected] on 1 Sep 2009 at 1:36

Provide access to the AtUnit Spring context from the unit test

What steps will reproduce the problem?
1. Use AtUnit in a Spring 2 unit test using the approach proposed in <a
href="http://arsenalist.com/2007/06/18/unit-testing-struts-2-actions-spring-juni
t/">Arenalist</a>
2. Try to merge the Spring context used by Struts (which contains the
actions) with the Spring context used by AtUnit (which contains the mocks)
3. No solution found! This same problem may arise in other scenarios other
than a Struts 2 unit test.

What is the expected output? What do you see instead?
There's no easy way of merging both contexts.

What version of the product are you using? On what operating system?
AtUnit 1.0

Please provide any additional information below.

I've implemented a solution for this (with good results) using a new AtUnit
Annotation that marks a field so atunit.spring.SpringContainer can inject
the AtUnit Spring context there. This way it's easy to merge both contexts.

I've also implemented the unit tests, so if you think this is a good design
you could give me write access to the repository so I can update it with
the changes or send me an email.

Original issue reported on code.google.com by [email protected] on 9 Jan 2008 at 5:23

Bug on GuiceContainer

When the test class is a module, the test gets created twice: first time for 
the module and second for the test, this doesn't allow us to share instance 
variables between the module and the test, forcing us to us statics.

To fix, on GuiceContainer change the createTest method for:

public Object createTest(Class<?> testClass, Map<Field, Object> fieldValues) 
throws Exception {

    FieldModule fields = new FieldModule(fieldValues);

    Object newInstance = testClass.newInstance();

    Injector injector;
    if (Module.class.isAssignableFrom(testClass)) {
      injector = Guice.createInjector(fields, (Module) newInstance);
    } else {
      injector = Guice.createInjector(fields);
    }
    injector.injectMembers(newInstance);
    return newInstance;
  }


Original issue reported on code.google.com by [email protected] on 8 Dec 2011 at 7:41

Maven repository

I'm an avid Maven user and I would very much like to use AtUnit. Since AtUnit 
is not packaged and 
deployed to a Maven repository it's a bit hard. I know that I can install 
AtUnit locally / deploy to my 
own repository, but that is a bit of a hackish way of doing it IMO.


Original issue reported on code.google.com by [email protected] on 19 Nov 2008 at 10:30

AtUnit doesn't see inherited fields


AtUnit only sees fields declared on the test class itself.  Inherited
fields (including @Unit and @Mock fields) should also be handled appropriately.

Original issue reported on code.google.com by [email protected] on 28 Oct 2007 at 2:43

support Spring as container

AtUnit should support Spring as an IoC container.  Spring is a bit trickier
than Guice, as configuration by XML and annotation (in Spring 2.5) should
ideally both be supported.

Original issue reported on code.google.com by [email protected] on 28 Oct 2007 at 2:46

When using with jmock 2.5.1 mockery method assertIsSatisfied() is not called automatically after the test.

When using with jmock 2.5.1 mockery method assertIsSatisfied() is not 
called automatically after the test.

Please see the code below. It passes if checkMockery method is removed from 
the test.

import javax.management.MBeanServer;
import javax.management.ObjectName;

import atunit.AtUnit;
import atunit.Mock;
import atunit.MockFramework;
import atunit.Stub;
import atunit.Unit;
import static org.hamcrest.CoreMatchers.equalTo;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AtUnit.class)
@MockFramework(MockFramework.Option.JMOCK)
public class CallStatisticsJMXExporterTest{
    Mockery ctx;
    @Stub CallRegistry callRegistry;
    @Mock MBeanServer mBeanServer;
    @Unit CallStatisticsJMXExporter callStatisticsJMXExporter;

    @Before
    public void setUp(){
        callStatisticsJMXExporter = new 
CallStatisticsJMXExporter(callRegistry, mBeanServer);        
    }

    @After public void checkMockery(){
        ctx.assertIsSatisfied();
    }


    @Test
    public void mbeanIsRegistered() throws Exception{
        ctx.checking(new Expectations(){{
            one(mBeanServer).registerMBean(with(any(Object.class)), with( 
equalTo( new ObjectName("object:method=method1"))));
        }});
        callStatisticsJMXExporter.export(new CallKey("object", "method1"));

    }

}

public class CallStatisticsJMXExporter{
    public CallStatisticsJMXExporter(CallRegistry inMemoryCallRegistry, 
MBeanServer platformMBeanServer){
    }

    public void export(CallKey callKey){
    }
}


Original issue reported on code.google.com by [email protected] on 28 Oct 2008 at 12:40

Injecting explicit mock does not work.

Given that Something is dependent on Dependency, the following test code 
fails to properly inject an instance of Dependency:

@RunWith(AtUnit.class)
@MockFramework(MockFramework.Option.EASYMOCK)
@Container(Container.Option.GUICE)
public class SomethingTest implements Module {

  @Inject @Unit Something something;

  Dependency mockInstance = createMock(Dependency.class);

  public void configure(Binder b){
    b.bind(Dependency.class).toInstance(mockInstance);
  }

}

What is the expected output? What do you see instead?

I expected to see mockInstance to be inside Something, however when I 
look inside the debugger, the mockInstance inside Something is a different 
object than the one within SomethingTest, which makes it impossible to set 
expectations on mockInstance.

-Tristan


Original issue reported on code.google.com by [email protected] on 19 Dec 2009 at 8:36

before-and-after examples

Some examples of refactoring existing ugly tests to use AtUnit would serve
as good introductory and advertisement material.  It would be especially
useful to show the refactoring step-by-step somehow-- screencasts maybe?

One solid example of each container paired with a mock framework would be a
pretty good start.  Ideally, these examples would be taken from real
projects and would use real people, not actors.

Original issue reported on code.google.com by [email protected] on 27 Nov 2007 at 4:03

GuiceContainer: don't bind multiple indistinguishable fields

If a test has several mock or stub fields which are differentiated only by
name, binding those fields in Guice will result in a collision and Guice
will throw an exception.

Solution:  By default, if AtUnit sees multiple fields of the same type
which are distinguishable only by name, it should refrain from binding them.  

If omitting those bindings causes a dependency to go unfulfilled, Guice
will throw an exception, which it would have done in the event of collision
anyway.  AtUnit can catch that exception, guess the cause, and advise the
test author on how to avoid it (by distinguishing the fields through
annotations, for instance).

Original issue reported on code.google.com by [email protected] on 19 Nov 2007 at 3:41

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.