Alternative table setup

9 views
Skip to first unread message

Matt Savage

unread,
Dec 19, 2011, 2:45:49 AM12/19/11
to yat...@googlegroups.com
What's the current plan for non-annotation-based table tests?

Daniel Worthington-Bodart

unread,
Dec 19, 2011, 3:42:30 AM12/19/11
to yat...@googlegroups.com
My ideas were pretty basic but maybe one of these:

@TableId("foo")
public TableData getTableData() {
    // create you strongly typed table data here
}

@Test
@TableRef("foo")
public void someMethod(User user){

}

or if this is possible

public TableData getTableData() {
    // create you strongly typed table data here
}

@Test
@LoadTableData(from(method(on(TestClass).getTableData()))) 
public void someMethod(User user){

}


or we could just go naming convention like JUnit3


public TableData someMethodData() {
    // create you strongly typed table data here
}

@Test
public void someMethod(User user){

}

Matt Savage

unread,
Dec 19, 2011, 4:04:04 AM12/19/11
to yat...@googlegroups.com
Any more pros or cons to add to the ones inline below?

On 19 December 2011 19:42, Daniel Worthington-Bodart <d...@bodar.com> wrote:
@TableId("foo")
public TableData getTableData() {
    // create you strongly typed table data here
}

@Test
@TableRef("foo")
public void someMethod(User user){

}

+ Immediately obvious how it works
+ Allows reuse of TableData methods (although I can't think of a use case for this right now?)

- Verbose
- Annotations generally end up sucking for unexpected reasons (but I can't think of any immediate problems)
- Can't reuse TableData methods without delgation (use case?)

public TableData getTableData() {
    // create you strongly typed table data here
}

@Test
@LoadTableData(from(method(on(TestClass).getTableData()))) 
public void someMethod(User user){

}

+ Find usages works, as does jump-to
+ TableData method could be on a different class without delegation (use case?)

- Would probably make some people's eyes bleed
- More magic than is absolutely necessary
- Would probably need to read the docs to work out how to do it
 
public TableData someMethodData() {
    // create you strongly typed table data here
}

@Test
public void someMethod(User user){

}

+ Super-concise

- Not clear how it works unless you already know (convention over configuration)
- Can't reuse TableData methods without delegation (use case?)

Mike Hogan

unread,
Dec 19, 2011, 4:28:26 AM12/19/11
to yat...@googlegroups.com
I'd like if there was a facility in yatspec to construct things using yadic, and test cases had the change to register into that container before construction starts. A TestScopeContainer to use UI terminology. This would allow:

public void templateMethodToRegisterThings(Container container) {
container.addInstance(Properties.class, loadSomeTestPropertiesOrWhatever());
}

@Test
public void someMethod(ArbitrarilyComplexTestData data) {
}

public static class ArbitrarilyComplexTestData {
public ArbitrarilyComplexTestData(Properties properties) {
...whatever...
}
}

If you also added an AnnotationsOnTestScopeContainer, then you could have ArbitrarilyComplexTestData instances constructed with parameters:

@Test
@TestValue(name = "fred")
@TestValue(age = "21")
public void someMethod(ArbitrarilyComplexTestData data) {
}

and

public static class ArbitrarilyComplexTestData {
public ArbitrarilyComplexTestData(AnnotationValues values) {
this.name = values.get("name");
this.age = values.get("age");
}
}

or maybe pass a map instead of 'AnnotationValues'.

Inspired by what you did for given/when/then in Propidle Matt.


On 19 Dec 2011, at 08:42, Daniel Worthington-Bodart wrote:

> My ideas were pretty basic but maybe one of these:
>

> @TableId("foo")
> public TableData getTableData() {
> // create you strongly typed table data here
> }
>
> @Test
> @TableRef("foo")
> public void someMethod(User user){
>
> }
>

> or if this is possible
>

> public TableData getTableData() {
> // create you strongly typed table data here
> }
>
> @Test
> @LoadTableData(from(method(on(TestClass).getTableData())))
> public void someMethod(User user){
>
> }
>
>

> or we could just go naming convention like JUnit3
>
>

> public TableData someMethodData() {
> // create you strongly typed table data here
> }
>
> @Test
> public void someMethod(User user){
>
> }
>
>
>
>
>
>
>

> On 19 December 2011 07:45, Matt Savage <matthew...@gmail.com> wrote:

Matt Savage

unread,
Dec 19, 2011, 5:51:30 AM12/19/11
to yat...@googlegroups.com
*letting it sink in...*
Reply all
Reply to author
Forward
0 new messages