Note that there are some explanatory texts on larger screens.

plurals
  1. POThinking about unit tests structure
    primarykey
    data
    text
    <p>I am thinking about how to write tests for my project. At the moment, tests structure is like this:</p> <pre><code>RealClass { method1; method2; ... } </code></pre> <p>and exactly same test class structure: </p> <pre><code>TestClass { testMethod1; testMethod2; ... } </code></pre> <p>But, I do not like it, because I am putting too much test cases in one test method... </p> <p>May be I should use structure like this: </p> <pre><code>TestClass { testMethod1Opt1; testMethod1Opt2; ... testMethod2Opt1; ...} </code></pre> <p>How are you writing Unit tests?</p> <h3>Example of my test code: (Very simple test)</h3> <pre><code>public void testIsAppUser() { // My (Artem`s Zinnatullin) uId final long artemZinnatullinUId = 172672179; try { assertTrue(usersApi.isAppUser(artemZinnatullinUId)); } catch (Exception e) { fail(e.getMessage()); } // Pavel`s Durov uId final long durovUId = 1; try { assertFalse(usersApi.isAppUser(durovUId)); } catch (Exception e) { fail(e.getMessage()); } // By default uId == current user`s (who has authorized) uId try { assertTrue(usersApi.isAppUser(null)); } catch (Exception e) { fail(e.getMessage()); } } </code></pre> <h3>What I am thinking about:</h3> <pre><code>public void testIsAppUser1() { // My (Artem`s Zinnatullin) uId final long artemZinnatullinUId = 172672179; try { assertTrue(usersApi.isAppUser(artemZinnatullinUId)); } catch (Exception e) { fail(e.getMessage()); } } public void testIsAppUser2() { // Pavel`s Durov uId final long durovUId = 1; try { assertFalse(usersApi.isAppUser(durovUId)); } catch (Exception e) { fail(e.getMessage()); } } public void testIsAppUser3() { // By default uId == current user`s (who has authorized) uId try { assertTrue(usersApi.isAppUser(null)); } catch (Exception e) { fail(e.getMessage()); } } </code></pre> <p>Give me advice please.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload