如何在 Gradle 的测试中显示详尽的错误信息
在build.gradle
中添加如下设置:
1 | test { |
参考:
在build.gradle
中添加如下设置:
1 | test { |
参考:
I tried to resize a Client Web Part with non integers as size, but it failed. And that’s why:
1 | var regex = RegExp(/(<\s*[Mm]essage\s+[Ss]ender[Ii]d\s*=\s*([\dAaBbCcDdEdFf]{8})(\d{1,3})\s*>[Rr]esize\s*\(\s*(\s*(\d*)\s*([^,\)\s\d]*)\s*,\s*(\d*)\s*([^,\)\s\d]*))?\s*\)\s*<\/\s*[Mm]essage\s*>)/); |
The regular expression shows that it doesn’t allow float numbers.
I’m learning how to upgrade SharePoint App, and I met a problem when I added a new list field in the upgrade.
The document mentioned that if you added a field to a content type in the feature, you should add an AddContentTypeField
element to the VersionRange
section. But there is no ContentType
in my app, it only has a ListDefinition
. I tried to add an AddContentTypeField
, unfortunately it throws exception.
So I tried another way. The document also mentioned that if you have changed a file that is referenced in an elements manifest file, you have to copy the ElementManifest
element for the component from the ElementManifests
section to the ApplyElementManifests
section. When we added a new field to list, the Schema.xml
is changed, although it’s not referenced in a ElementManifest
, I still copied MyList/Elements.xml
to ApplyElementManifests
, so it looks like this:
1 | <UpgradeActions> |
And it works. Hope it’s helpful.
Reference:
Today I met a bug in SharePoint 2013, I failed to resize my app part by using postMessage
. Here is my code:
1 | var message = "<Message senderId=" + senderId + ">" + "resize(" + width + "," + height + ")</Message>"; |
It fails to work if I set Chrome Type
to None
or Border Only
. And I found an error message in console:
1 | Uncaught TypeError: Cannot read property 'style' of null |
Then I located the code in my web part page which throws the error:
1 | if (resizeWidth) |
It tries to find the title element and resize it. But document.getElementById(webPartDivId + '_ChromeTitle')
returns null if Chrome Type
is None
or Border Only
!
Because the app part doesn’t have a title under these 2 modes. Of course it will throw exception.
This bug is described here, you can install a patch to fix this bug.
After the patch is installed, you can find that the original code is changed, it will resize the element only if it’s not null:
1 | if (resizeWidth) |
Hope it’s helpful.
SharePoint App Model
provides a new approach to SharePoint development. And here is the question: where to save app data? There are several ways to save data in an app, you can create a list or connect to a database in Windows Azure or set custom properties in AppManifest.xml
. But we can also save data to the property bag of a SharePoint web.
Adding custom property to web is easy. Let’s just see the code:
1 | var context = SP.ClientContext.get_current(); |
How do we know “MyProperty” is really added to web? We can check it here: http://your_web/_api/web/AllProperties?$select=MyProperty
. The result looks like this:
1 | <?xml version="1.0" encoding="utf-8" ?> |
We have two approaches to read properties from web: props.get_item("PropertyKey")
or REST API
.
1 | var context = SP.ClientContext.get_current(); |
1 | var executor = new SP.RequestExecutor('http://your_web'); |
And here is the json query result, very straightforward:
1 | { |