Should I use 'to'?

I have two verbs in a sentence. I know I have to use 'to' before each verb. But in this case it sounds a little bit strange to me.

Should I use to there?

Test that this method returns right data and to works correctly.


No.

Your sentence is grammatically incorrect as given. Without to and with an extra the, it is correct:

Test that this method returns the right data and works correctly.

(The is needed with right data since right implies that there is only one acceptable set of data.)

I’m not sure why you would expect that to to be there.


In addition to the excellent answers already given, I wanted to make a pitch for using parallel structure. It has helped me figure out some otherwise tricky sentence constructions. In general, you want your verbs to match when they are associated using an and or an or. In your sentence:

Test that this method returns right data and to works correctly.

the verbs that you want to match are "returns" and "works", because they are joined by the and. This would give you two alternatives:

Test that this method returns right data and works correctly.

OR

Test that this method to return right data and to work correctly.

Now since "returns" and "works" goes with "this method", the infinitive doesn't work here, so we're left with:

Test that this method returns right data and works correctly.

(@PLL is right about adding the "the" as well.)

As an example of how you might structure the sentence to use parallel infinitives, consider:

Run a test to see if this method returns the correct data and to check for errors.

In this construction, "to see" and "to check" are coordinated with the and, so they should match. Matching with infinitives is less strict, though, because it is okay to drop the extra to:

Run a test to see if this method returns the correct data and check for errors.

Although personally, I think it is less clear this way.

This crib sheet has some other examples of parallelism, including other parts of speech.


Without really knowing what your example sentence is supposed to mean... I can tell you that "to works" is incorrect. It's either "to work" or "works".