View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit;
16  
17  import org.htmlunit.junit.BrowserRunner;
18  import org.junit.AfterClass;
19  import org.junit.BeforeClass;
20  import org.junit.Test;
21  import org.junit.runner.RunWith;
22  
23  /**
24   * Tests for {@link BrowserRunner}.
25   *
26   * @author Marc Guillemot
27   */
28  @RunWith(BrowserRunner.class)
29  public class BrowserRunnerTest extends SimpleWebTestCase {
30      private static int Counter_ = 0;
31  
32      /**
33       * Setup.
34       */
35      @BeforeClass
36      public static void setupClass() {
37          Counter_++;
38      }
39  
40      /**
41       * Tear down.
42       */
43      @AfterClass
44      public static void tearDownClass() {
45          Counter_--;
46      }
47  
48      /**
49       * Methods marked @BeforeClass (and @AfterClass) were wrongly called twice when using {@link BrowserRunner}.
50       */
51      @Test
52      public void thatBeforeClassMethodHasBeenCalledOnlyOnce() {
53          assertEquals(1, Counter_);
54      }
55  }