Question: I create a loop in Wordpress with the condition like this:

1. Display a specific post format (example: video)
2. Limiting the post number. In this case, I only want to display 2 posts.

Here my code:

```
 <?php $i = 1; if (have_posts()) : while (have_posts() && $i < 3) : the_post(); ?>
 <?php get_template_part( 'content-video', get_post_format() ); ?>
 <?php $i++; endwhile; ?>
 <?php else : ?>
 <?php get_template_part( 'content', 'none' ); ?>
 <?php endif; ?>

```

I already have file name content-video.php.

Unfortunately, the loop does not work. Only displayed the first post, not a specific post (video post format) with template from content-video.php.

Appreciate for any help, or alternative code. Thanks in advance.

Answer: 
You can [use `Assume`](http://junit.sourceforge.net/javadoc/org/junit/Assume.html) to turn tests on/off conditionally:

> 
> A set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean the code is broken, but that the test provides no useful information.
> 
> 
>
You can do this with JUnit Rules. 

There's a whole blog post dedicated to exactly your question [here](http://www.mikereedell.com/2011/12/15/JUnit-Conditional-Ignore-Using-Rules.html), but in short, you do the following: 

1. Create a class that implements the `org.junit.rules.TestRule` interface. This interface contains the following method:  

`Statement apply(Statement base, Description description);`  

The `base` argument is actually your test, which you run by calling `base.execute()` -- well, the `apply()` method actually returns a `Statement` anonymous instance that will do that. In your anonymous `Statement` instance, you'll add the logic to determine whether or not the test should be run. See below for an example of a `TestRule` implementation that doesn't do anything except execute your test -- and yes, it's not particularly straighforward.
2. Once you've created your `TestRule` implementation, then you need to add the following lines to to your JUnit Test Class:  

`@Rule  

 public MyTestRuleImpl conditionalTests;`  

Remember, the field *must* be public.

And that's it. Good luck -- as I said, you may have to hack a little, but I believe there's a fair amount explained in the blog post. Otherwise, there should be other information on the internets (or in the JUnit sourc code). 

Here's a quick example of a TestRule implementation that doesn't do anything. 

```
public abstract class SimpleRule implements TestRule {
    public Statement apply(final Statement base, final Description description) {
        return new Statement() {
            public void evaluate() throws Throwable {
                try {
                    base.evaluate();
                } catch (Throwable t) { 
                    t.printStackTrace();
                }
            }
        };
    }
}

```