Hi Paul,

I have this test method
        @Inject
        private TestPageResultRetriever<RBUSelection> retriever;

        @Inject
        private RBUTypeRepository repository;

        @Override
        protected void doSetUp() throws Exception
        {
        }

        @Test(groups = "rbudisplay")
        public void test_rbuselection_fulltype() throws Exception
        {
                Document doc = 
tester.renderPage("multiselect/rbuselectiontestpage");

                List<Element> selectelements =
TapestryXPath.xpath("//select").selectElements(doc);
                assertEquals(selectelements.size(), 2);
                Iterable<Element> options = getSelectElementOptions(doc,
"//table/tr[1]//select[1]");
                assertEquals(Iterables.size(options), 3);
                selectOptionElement(options, 1);
                Element textfield =
TapestryXPath.xpath("//table/tr[1]//input[1]").selectSingleElement(doc);
                textfield.forceAttributes("value", "1");

                Iterable<Element> options2 = getSelectElementOptions(doc,
"//table/tr[2]//select[1]");
                selectOptionElement(options2, 1);
                Element hidden =
TapestryXPath.xpath("//table/tr[2]//input[1]").selectSingleElement(doc);
                assertNotNull(hidden);

                Element form = doc.getElementById("rbuselection");
                tester.submitForm(form, new HashMap<String, String>());
                RBUSelection selection = getSubmittedRBUSelection(1L);
                assertNotNull(selection);

                RBU rbu = selection.getSelection();
                assertEquals(rbu.getId(), Long.valueOf(2L));
        }
        private RBUSelection getSubmittedRBUSelection(Long id)
        {
                RBUType type = repository.findById(id, false);
                RBUSelection entry = new RBUSelection(type);
                RBUSelection selection = retriever.getEntry(entry);
                return selection;
        }

When I run the test within a suite the test fails in the
getSubmittedRBUSelection method on the first statement which as you can see
is being called at the forth statement before the end of the testmethod.
the repository is already been used in the page aswell otherwise I would
have recieved an exception from there.

When i run the test alone with its class it works 

Paul Field wrote:
> 
> Hi Rolf,
> 
> 
>> Hi I am using Testify to inject a fake repository into my testng test 
> but I
>> come op to a problem.
>> 
>> when i first access the fake repository it gets injected however the 
> second
>> time i access the repository I get a null pointer exception.
>> 
>> Now comes another strange thing when i debug everything works fine and 
> the
>> repository gets injected perfectly.
> 
> At the moment Testify's TestNG integration is using @BeforeClass to 
> process the @Inject annotations. So I can see that there might be possible 
> scenarios that match yours: something where the '@Inject'ed field is 
> cleared between tests for example... but it's hard to know exactly what's 
> happening from your description.
> 
> Could you give some more information (e.g. code examples) that show the 
> problem? Also, when you debug, are you running exactly the same suite as 
> when you aren't debugging? And is the behaviour consistent if you try this 
> multiple times?
> 
> Thanks,
> 
> Paul
> 
> 
> 
> 
> 
> 
> ---
> 
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and delete this e-mail. Any
> unauthorized copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
> 
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for
> additional EU corporate and regulatory disclosures.
> 

-- 
View this message in context: 
http://www.nabble.com/Testify-injection-only-works-once-per-test-tp24665202p24679761.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to