usability testing – How do you know what to test at the right time on a product?

Really good question! I used to have this conundrum for a while and then I found the solution in the Google Design Sprint.

You can find more information about it online but basically, the methodology answers your question exactly : “What is the the next step right now?”

It was created by Google Ventures (the company that acquires new startups for Google and helps them get on the right track) and now the methodology is open to use by anyone.

In a nutshell: In 4 days you bring in all your stakeholders and you run a series of exercises: Monday – Mapping and Sketching, Tuesday – Decisions and Storboarding, Wednesday – Prototyping and Thursday – Testing. In one week you can clarify the vision of your organization and know what the next step is.

You should try it! It works wonders and it saves so much time!

python – My code is passing only few test cases [Trie data structure]

I have tested my code against all possible test cases. Ex: word present, not present in dictionary; given word is prefix of existing words, upper case, lower case. They passed. But not sure what I missed. 2 test cases are failing

Question:

Peter found a digital dictionary which is far better than normal
dictionaries. The digital dictionary has an input field in which one
can search any string and the dictionary displays all the words whose
prefix is that input string in lexicographical order. Now you are
given a task to make your own digital dictionary. You will be given
words that you can store in your database and then you need to design
the search functionality. And if no such words are available for a
given search word, add this word to your dictionary.

Input Format Single integer N which denotes the number of words which
are to be stored in the database of the dictionary. N lines of input,
where in each line there is a string made up of lowercase/uppercase
letter Single integer Q which denotes the number of queries. Q number
of lines describing the query string on each line given by user.

Constraints 1≤N≤30000 sum(len(stringi)) ≤ 2∗10^5 1≤Q≤10^3

Output Format If word with prefix exists in the database, then you
need to print all the words with the given prefix in lexicographical
order in separate lines else you need to print “No suggestions”
without the inverted commas.

Sample Input

4

pet

peter

rat

rack

5

pe

pet

r

rac

rat

Sample Output

pet

peter

pet

peter

rack

rat

rack

rat

Explanation

For query 1 : Input = “pe”

We print “pet” and “peter”.

For query 2 : Input = “pet”

We print “pet” and “peter”.

For query 3 : Input = “r”

We print “rack” and “rat”.

For query 4 : Input = “rac”

We print “rat.

For query 5 : Input = “rat”

We print “rat”.

import sys
from collections import deque

class TrieNode:
    def __init__(self, character):
        self.character = character
        self.children = dict()
        self.is_word_end = False


class Trie:
    def __init__(self):
        self.root = TrieNode('$')

    def insert(self, word):
        ctn = self.root  # current trie node
        for i, char in enumerate(word):
            if ctn.children.get(char) is None:
                ctn.children(char) = TrieNode(char)
            ctn = ctn.children(char)
            if i == len(word) - 1:
                ctn.is_word_end = True

    def find_super_strings(self, given_prefix_str):
        ctn = self.root  # current trie node
        prefix_list = ()
        for char in given_prefix_str:
            if ctn.children.get(char) is None:
                self.insert(given_prefix_str)
                print('No suggestions')
                prefix_list.clear()
                return
            ctn = ctn.children(char)
            prefix_list.append(char)
        prefix = ''.join(prefix_list)
        suffix = deque()
        # print('given_prefix_str: ', given_prefix_str, 'prefix: ', prefix_list)
        self.dfs(ctn, prefix, suffix)

    def dfs(self, pnode, prefix, suffix_deck):  # parent node
        if len(pnode.children) == 0:
            print(prefix, ''.join(suffix_deck), sep='')
            if len(suffix_deck) > 0:  # remove char while backtracking
                suffix_deck.pop()
            return
        elif pnode.is_word_end:
            print(prefix, ''.join(suffix_deck), sep='')
        for key in sorted(pnode.children.keys()):  # sorted used for chronological order
            cnode = pnode.children(key)  # child node
            suffix_deck.append(key)
            self.dfs(cnode, prefix, suffix_deck)
        if len(suffix_deck) > 0:  # remove char while backtracking
            suffix_deck.pop()


n = int(input())
trie = Trie()
while n > 0:
    trie.insert(input())
    n -= 1
q = int(input())
# print()
while q > 0:
    # print('###',str,'###')
    trie.find_super_strings(input())
    q -= 1

design – Java: Splitting a large unit test class

The project (Java/Spring) I currently work on has a rather large unit-test class for one of its services : more than 1000 lines, several Nested class (one per big functionality), some tests without a Nested class, …

Finding this file rather difficult to read, and to manage (a modification in the service, and you have to take time to find the corrects tests to fix/update), I proposed to split the class to have one test file per Nested Class, each one linked to a “principal” test file, which will be managing the Mock & the tests without Nested Class. All the tests files would be put into a specific package.

I am wondering if this would be a good thing to do? or if it was something to avoid to do ?

I hope i was clear enough.
Have a nice day

javascript – Unit testing multiple features in one test

I’m writing a small utility class to create an abstraction for addEventListener (JavaScript/DOM)

Let’s say I have to test for these features:

  1. Single event target with a single event
  2. Multiple events
  3. Multiple event targets
  4. Delegated events
  5. Once

Now if I understand unit testing properly, I should create a test for each feature.

However, is there a need to test combined features? E.g.

  1. Multiple events + multiple targets
  2. Multiple event targets + delegated events
  3. Multiple event targets + delegated events + multiple events

Should I implement those combined tests in addition to single feature tests, or should I believe that I am fully covered by the single feature tests?

design – Which is preferred: subclass double or create extension methods to test (relative) equality due to floating point differences?

I am writing financial calculation software using .NET C#, which needs to be blazingly fast. There is a lot of fractional math. So using decimal type is pretty much out of the question, given its poor speed relative to using double. But of course double has its problems testing for equality, with floating point rounding issues.

My options seem to be subclassing double and overriding ==, < and >; versus creating extension methods for double equivalent to these. My tendency is to go with the latter – less code to change and maybe it will be less confusing to others reading the code later? Is there another option? What are other good reasons to choose one over the other?

“file is locked” when visual studio executes unit test

I developed near 300 unit tests, but sometimes, when trying to develop new tests, or just execute old tests, I got below error (for some of assemblies):

Could not copy "X.dll" to "binDebugX.dll". 
Exceeded retry count of 10. Failed. 
The file is locked by: "Microsoft Visual Studio 2019 (37736)"

After that only restarting visual studio resolves problem. Normally this error will be thrown when I changed tests or library and try to execute test again.

Any idea how can I resolve this error?

signal – Field test on iPhone 7. Can’t locate “rsrp0”

I have an unlocked iPhone 7 on T-Mobile, model A1660 on IOS 14.0.1. I’m trying to find the cell signal strength by running the field test as described here. From my reading, rsrp0 is the best option to get a realistic idea of the true cell signal strength. However when I click on the Serving Cell Measurements, instead of seeing a # of fields like “rsrp1”, “rsrp0”, etc, I get the below. Would one of these fields (Measured RSRP perhaps?) provide equivalent information to rsrp0?

Serving Cell Measurements

8 – How do I run a BrowserTestBase functional test with blocks?

I have a module that defines a custom block and places it using a block.block.block_name.yml file that I generated by exporting the placement of the block on a dev site. I’ve unit-tested the block code, but now I want a functional test that will tell me whether the block is correctly placed and rendering to the right users;

<?php

namespace DrupalTestsmy_moduleFunctional;

use DrupalTestsBrowserTestBase;
use Drupalmy_moduleEnablerService;
use DrupalnodeEntityNode;
use DrupalnodeNodeInterface;
use DrupaluserEntityUser;

/**
 * Main test class for the my_module module
 *
 * @group my_module
 */

class ImplementationTests extends BrowserTestBase {

  public $defaultTheme = 'bootstrap';

  /**
   * Modules to enable.
   *
   * @var array
   */

  public static $modules = ('block', 'node', 'my_module', 'user');

  private NodeInterface $node;
  private User $user;

  # from https://www.drupal.org/project/bootstrap/issues/2860072#comment-12287718
  protected function getConfigSchemaExclusions() {
    return array_merge(parent::getConfigSchemaExclusions(), ('bootstrap.settings'));
  }
  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
  }

  /**
   * some test
   */
  public function test_nothing() {
    $this->assertTrue(true);
  }
}

However, when I run this, I get this error:

DrupalTestsimplementationsFunctionalImplementationTests::test_hookFormFormIdAlter_CreateImplementationForm
Trying to access array offset on value of type null

/opt/drupal/web/core/lib/Drupal/Core/Block/BlockPluginTrait.php:90
/opt/drupal/web/core/lib/Drupal/Core/Block/BlockPluginTrait.php:74
/opt/drupal/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php:85
/opt/drupal/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php:99
/opt/drupal/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php:55
/opt/drupal/web/core/modules/block/src/BlockPluginCollection.php:34
/opt/drupal/web/core/modules/block/src/Entity/Block.php:156
/opt/drupal/web/core/modules/block/src/Entity/Block.php:166
/opt/drupal/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:291
/opt/drupal/web/core/modules/block/src/Entity/Block.php:344
/opt/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:494
/opt/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:449
/opt/drupal/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:263
/opt/drupal/web/core/lib/Drupal/Core/Entity/EntityBase.php:339
/opt/drupal/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:591
/opt/drupal/web/core/lib/Drupal/Core/Config/ConfigInstaller.php:373
/opt/drupal/web/core/lib/Drupal/Core/Config/ConfigInstaller.php:248
/opt/drupal/web/core/lib/Drupal/Core/Config/ConfigInstaller.php:152
/opt/drupal/web/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php:75
/opt/drupal/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php:287
/opt/drupal/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
/opt/drupal/web/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:464
/opt/drupal/web/core/tests/Drupal/Tests/BrowserTestBase.php:581
/opt/drupal/web/core/tests/Drupal/Tests/BrowserTestBase.php:400
/opt/drupal/web/modules/custom/implementations/tests/src/Functional/ImplementationTests.php:40
/opt/drupal/vendor/phpunit/phpunit/src/Framework/TestResult.php:685

Looking at the first file in the stack (/opt/drupal/web/core/lib/Drupal/Core/Block/BlockPluginTrait.php:90), I see this:

 80   /**
 81    * Returns generic default configuration for block plugins.
 82    *
 83    * @return array
 84    *   An associative array with the default configuration.
 85    */
 86   protected function baseConfigurationDefaults() {
 87     return (
 88       'id' => $this->getPluginId(),
 89       'label' => '',
 90       'provider' => $this->pluginDefinition('provider'),
 91       'label_display' => BlockPluginInterface::BLOCK_LABEL_VISIBLE,
 92     );
 93   }

My guess is that BrowserTestBase needs some additional code to properly set up the blocks module, but I’m not sure what else I need to do. Any ideas?