+ Start a Discussion
Frank MamoneFrank Mamone 

How do I unit test VF controller?

New to Unit Testing....

 

When running this statement using Eclipse Force IDE, I get no results when running Test for a test class, but get correct results when using Execute Anonymous:

 

Integer startCountFeedPosts =[Select count() From CollaborationGroupFeed where parentId in (select id from CollaborationGroup where name='All Mamotek Solutions')];

 

Thank you.

 

Frank

Abhi_TripathiAbhi_Tripathi

Hey

 

Just use this on your page

 

but make this "startCountFeedPosts" public with get; set; on your Apex class

 

{!startCountFeedPosts }

 

Thanks

Abhi

Frank MamoneFrank Mamone
Perhaps I was not clear.

This is part of the Apex course from the partner site. It teaches how to run unit tests.

So, I when I said Run Test, I meant that in Eclipse, I right-click the class and choose "Run Tests".

The line returns 0 records.

Then, I test the same line using Execute Anonymous tab in Eclipse and it works returns 1, which is correct.

Thanks again.