1

I'm using JSF 2.2 and (as a lot of people) I've some difficulties while testing.

In the back-end I'm using Spring, so I've available some annotations that helps me in order to be more effective with tests. A class that tests something related to Spring have this skeleton

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringCoreConfiguration.class, loader = AnnotationConfigContextLoader.class)
@Transactional
@Rollback(true)
@ActiveProfiles("test")
public class ManagerToTest {

    @Autowired
    ...

@Test
public void testSomething(){...}

But for JSF for me is not clear in which way I can test a class with the following scheleton

@ManagedBean
@ViewScoped
public class someController{
@ManagedProperty
...

public void someControllerMethod(){}
}

Is it possible to create some "test environment" like the one used in the back-end, in order to test the controller methods?

Is it possible to auto inject the @ManagedProperty classes or is a task that I must set manually?

Or I've an erroneous point of view and I'm thinking not in correct way?

Thank you

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Gavi
  • 1,300
  • 1
  • 19
  • 39
  • I don't have any difficulty testing. I Just use a combination of frameworks that 'just works'. No Spring, CDI for injection (instead of JSF managed beans like you do and why not Spring managed beans?) And with using Arquilian, I have a good way of testing things. – Kukeltje Sep 03 '16 at 12:34
  • Is it possible to share a little example of what you've said? – Gavi Sep 03 '16 at 17:04
  • Sure, first hit in google https://hudson.jboss.org/hudson/job/JBoss-AS7-Docs/lastSuccessfulBuild/artifact/guides/developer-getting-started-guide/target/docbook/publish/en-US/html/kitchensink.html – Kukeltje Sep 03 '16 at 17:06
  • Thank you! I will try to study this information. – Gavi Sep 04 '16 at 00:04

0 Answers0